diff options
author | Iván Pérez <ivanperez2@gmail.com> | 2016-09-12 08:56:02 +0200 |
---|---|---|
committer | Iván Pérez <ivanperez2@gmail.com> | 2016-09-12 08:56:02 +0200 |
commit | b74a02cb217be5857afde7eb05ccdec686fe83f9 (patch) | |
tree | 23a88c9974d4d7a1d231e1c2e0ed5376a6bcf991 /cores/arduino/WString.cpp | |
parent | 0f959829ba264a8dabf726048fcee177bd58e1dc (diff) |
WString: add `toDouble`
`toFloat` internally converts into double and then truncates into a
float, so why not add a method to return the double?
Diffstat (limited to 'cores/arduino/WString.cpp')
-rw-r--r-- | cores/arduino/WString.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cores/arduino/WString.cpp b/cores/arduino/WString.cpp index 9975303..998cf22 100644 --- a/cores/arduino/WString.cpp +++ b/cores/arduino/WString.cpp @@ -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; +}
\ No newline at end of file |