Skip to content

Commit c7c6f70

Browse files
committed
WString: add toDouble
Port of arduino/Arduino#5362
1 parent fbbc70e commit c7c6f70

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cores/arduino/WString.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ long String::toInt(void) const
742742

743743
float String::toFloat(void) const
744744
{
745-
if (buffer) return float(atof(buffer));
745+
return float(toDouble());
746+
}
747+
748+
double String::toDouble(void) const
749+
{
750+
if (buffer) return atof(buffer);
746751
return 0;
747752
}

cores/arduino/WString.h

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ class String
190190
// parsing/conversion
191191
long toInt(void) const;
192192
float toFloat(void) const;
193+
double toDouble(void) const;
193194

194195
protected:
195196
char *buffer; // the actual char array

0 commit comments

Comments
 (0)