From e792ba2bd6480a556e50259e0e836ae4cf5ec371 Mon Sep 17 00:00:00 2001 From: Dino Tinitigan Date: Tue, 31 May 2016 17:03:06 -0700 Subject: [PATCH] Fix bug when using StringConstructor with doubles -Fixes issue of StringContructor instability with doubles --- cores/arduino/WString.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 996aebca..eaa901a4 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -136,7 +136,7 @@ String::String(float value, unsigned char decimalPlaces) int len = digitsBe4Decimal(value); init(); - if(decimalPlaces) len = 1 + ((int)decimalPlaces & 0x0FF); + if(decimalPlaces) len += 1 + ((int)decimalPlaces & 0x0FF); char buf[len+1]; *this = dtostrf(value, 0, decimalPlaces, buf); @@ -147,7 +147,7 @@ String::String(double value, unsigned char decimalPlaces) int len = digitsBe4Decimal(value); init(); - if(decimalPlaces) len = 1 + ((int)decimalPlaces & 0x0FF); + if(decimalPlaces) len += 1 + ((int)decimalPlaces & 0x0FF); char buf[len+1]; *this = dtostrf(value, 0, decimalPlaces, buf);