1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Add String::toDouble from upstream Arduino core (#5986)

Fixes #5985
This commit is contained in:
Earle F. Philhower, III 2019-04-14 15:33:15 -07:00 committed by david gauchard
parent e3de77f671
commit 3b9db65ea3
2 changed files with 10 additions and 2 deletions

View File

@ -829,17 +829,24 @@ void String::trim(void) {
// /*********************************************/ // /*********************************************/
long String::toInt(void) const { long String::toInt(void) const {
if(buffer()) if (buffer())
return atol(buffer()); return atol(buffer());
return 0; return 0;
} }
float String::toFloat(void) const { float String::toFloat(void) const {
if(buffer()) if (buffer())
return atof(buffer()); return atof(buffer());
return 0; 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 // global empty string to allow returning const String& with nothing
const String emptyString; const String emptyString;

View File

@ -241,6 +241,7 @@ class String {
// parsing/conversion // parsing/conversion
long toInt(void) const; long toInt(void) const;
float toFloat(void) const; float toFloat(void) const;
double toDouble(void) const;
protected: protected:
// Contains the string info when we're not in SSO mode // Contains the string info when we're not in SSO mode