diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 380a8e5033..6c341f89c5 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -742,6 +742,11 @@ long String::toInt(void) const float String::toFloat(void) const { - if (buffer) return float(atof(buffer)); + 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 5618c0c574..3dd590d129 100644 --- a/cores/arduino/WString.h +++ b/cores/arduino/WString.h @@ -161,6 +161,10 @@ class String void toCharArray(char *buf, unsigned int bufsize, unsigned int index=0) const {getBytes((unsigned char *)buf, bufsize, index);} const char * c_str() const { return buffer; } + char* begin() { return buffer; } + char* end() { return buffer + length(); } + const char* begin() const { return c_str(); } + const char* end() const { return c_str() + length(); } // search int indexOf( char ch ) const; @@ -186,6 +190,7 @@ class String // parsing/conversion long toInt(void) const; float toFloat(void) const; + double toDouble(void) const; protected: char *buffer; // the actual char array