mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-26 20:54:22 +01:00
WString: add toDouble
`toFloat` internally converts into double and then truncates into a float, so why not add a method to return the double?
This commit is contained in:
parent
2bfe164b9a
commit
4650c2c3d8
@ -740,6 +740,11 @@ long String::toInt(void) const
|
||||
|
||||
float String::toFloat(void) const
|
||||
{
|
||||
if (buffer) return float(atof(buffer));
|
||||
return 0;
|
||||
return float(toDouble());
|
||||
}
|
||||
|
||||
double String::toDouble(void) const
|
||||
{
|
||||
if (buffer) return atof(buffer);
|
||||
return 0;
|
||||
}
|
@ -190,6 +190,7 @@ public:
|
||||
// parsing/conversion
|
||||
long toInt(void) const;
|
||||
float toFloat(void) const;
|
||||
double toDouble(void) const;
|
||||
|
||||
protected:
|
||||
char *buffer; // the actual char array
|
||||
|
@ -742,6 +742,11 @@ long String::toInt(void) const
|
||||
|
||||
float String::toFloat(void) const
|
||||
{
|
||||
if (buffer) return float(atof(buffer));
|
||||
return 0;
|
||||
return float(toDouble());
|
||||
}
|
||||
|
||||
double String::toDouble(void) const
|
||||
{
|
||||
if (buffer) return atof(buffer);
|
||||
return 0;
|
||||
}
|
@ -190,6 +190,7 @@ public:
|
||||
// parsing/conversion
|
||||
long toInt(void) const;
|
||||
float toFloat(void) const;
|
||||
double toDouble(void) const;
|
||||
|
||||
protected:
|
||||
char *buffer; // the actual char array
|
||||
|
Loading…
x
Reference in New Issue
Block a user