From b74a02cb217be5857afde7eb05ccdec686fe83f9 Mon Sep 17 00:00:00 2001 From: Iván Pérez Date: Mon, 12 Sep 2016 08:56:02 +0200 Subject: WString: add `toDouble` `toFloat` internally converts into double and then truncates into a float, so why not add a method to return the double? --- cores/arduino/WString.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cores/arduino/WString.cpp') 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 -- cgit v1.2.3-18-g5258