Skip to content

Commit 23ca972

Browse files
sandeepmistrycalvinatintel
authored andcommitted
WString: add toDouble (#293)
Port of arduino/Arduino#5362
1 parent f818d7c commit 23ca972

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cores/arduino/WString.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,11 @@ long String::toInt(void) const
810810

811811
float String::toFloat(void) const
812812
{
813-
if (buffer) return float(atof(buffer));
814-
return 0;
813+
return (float)toDouble();
814+
}
815+
816+
double String::toDouble(void) const
817+
{
818+
if (buffer) return atof(buffer);
819+
return 0;
815820
}

cores/arduino/WString.h

+1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ class String
199199
// parsing/conversion
200200
long toInt(void) const;
201201
float toFloat(void) const;
202+
double toDouble(void) const;
202203
char * getCSpec(int base, bool issigned, bool islong);
203204

204205
protected:

0 commit comments

Comments
 (0)