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
0f959829ba
commit
b74a02cb21
|
@ -740,6 +740,11 @@ long String::toInt(void) const
|
||||||
|
|
||||||
float String::toFloat(void) const
|
float String::toFloat(void) const
|
||||||
{
|
{
|
||||||
if (buffer) return float(atof(buffer));
|
return float(toDouble());
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double String::toDouble(void) const
|
||||||
|
{
|
||||||
|
if (buffer) return atof(buffer);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -190,6 +190,7 @@ public:
|
||||||
// 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:
|
||||||
char *buffer; // the actual char array
|
char *buffer; // the actual char array
|
||||||
|
|
Loading…
Reference in New Issue