From 972123f6d52a88ddf001c2d43120e435585342ec Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Sun, 14 Apr 2019 10:29:09 -0700 Subject: [PATCH] Add String::toDouble from upstream Arduino core Fixes #5985 --- cores/esp8266/WString.cpp | 11 +++++++++-- cores/esp8266/WString.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cores/esp8266/WString.cpp b/cores/esp8266/WString.cpp index d949e2904e..69444696aa 100644 --- a/cores/esp8266/WString.cpp +++ b/cores/esp8266/WString.cpp @@ -829,17 +829,24 @@ void String::trim(void) { // /*********************************************/ long String::toInt(void) const { - if(buffer()) + if (buffer()) return atol(buffer()); return 0; } float String::toFloat(void) const { - if(buffer()) + if (buffer()) return atof(buffer()); return 0; } +double String::toDouble(void) const +{ + if (buffer()) + return atof(buffer()); + return 0.0; +} + // global empty string to allow returning const String& with nothing const String emptyString; diff --git a/cores/esp8266/WString.h b/cores/esp8266/WString.h index aecf9b4a62..11b12aa08a 100644 --- a/cores/esp8266/WString.h +++ b/cores/esp8266/WString.h @@ -241,6 +241,7 @@ class String { // parsing/conversion long toInt(void) const; float toFloat(void) const; + double toDouble(void) const; protected: // Contains the string info when we're not in SSO mode