Skip to content

Commit 3b9db65

Browse files
earlephilhowerd-a-v
authored andcommitted
Add String::toDouble from upstream Arduino core (esp8266#5986)
Fixes esp8266#5985
1 parent e3de77f commit 3b9db65

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cores/esp8266/WString.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -829,17 +829,24 @@ void String::trim(void) {
829829
// /*********************************************/
830830

831831
long String::toInt(void) const {
832-
if(buffer())
832+
if (buffer())
833833
return atol(buffer());
834834
return 0;
835835
}
836836

837837
float String::toFloat(void) const {
838-
if(buffer())
838+
if (buffer())
839839
return atof(buffer());
840840
return 0;
841841
}
842842

843+
double String::toDouble(void) const
844+
{
845+
if (buffer())
846+
return atof(buffer());
847+
return 0.0;
848+
}
849+
843850
// global empty string to allow returning const String& with nothing
844851

845852
const String emptyString;

cores/esp8266/WString.h

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class String {
241241
// parsing/conversion
242242
long toInt(void) const;
243243
float toFloat(void) const;
244+
double toDouble(void) const;
244245

245246
protected:
246247
// Contains the string info when we're not in SSO mode

0 commit comments

Comments
 (0)