diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index ce4e4f85..d577e002 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -810,6 +810,11 @@ long String::toInt(void) const float String::toFloat(void) const { - if (buffer) return float(atof(buffer)); - return 0; + return (float)toDouble(); +} + +double String::toDouble(void) const +{ + if (buffer) return atof(buffer); + return 0; } diff --git a/cores/arduino/WString.h b/cores/arduino/WString.h index 75a3e143..2ff259f8 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -199,6 +199,7 @@ class String // parsing/conversion long toInt(void) const; float toFloat(void) const; + double toDouble(void) const; char * getCSpec(int base, bool issigned, bool islong); protected: