From bd355a6c0722f85e1bc3f2ebf6df61012567d56d Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 23 Jan 2019 09:09:31 -0800 Subject: [PATCH] Document String.toDouble() --- .../Data Types/String/Functions/toDouble.adoc | 61 +++++++++++++++++++ .../Variables/Data Types/stringObject.adoc | 1 + 2 files changed, 62 insertions(+) create mode 100644 Language/Variables/Data Types/String/Functions/toDouble.adoc diff --git a/Language/Variables/Data Types/String/Functions/toDouble.adoc b/Language/Variables/Data Types/String/Functions/toDouble.adoc new file mode 100644 index 000000000..8e1ce800e --- /dev/null +++ b/Language/Variables/Data Types/String/Functions/toDouble.adoc @@ -0,0 +1,61 @@ +--- +title: "toDouble()" +categories: [ "Data Types" ] +subCategories: [ "StringObject Function" ] +--- + + + + + += toDouble() + + +// OVERVIEW SECTION STARTS +[#overview] +-- + +[float] +=== Description +Converts a valid String to a double. The input String should start with a digit. If the String contains non-digit characters, the function will stop performing the conversion. For example, the Strings "123.45", "123", and "123fish" are converted to 123.45, 123.00, and 123.00 respectively. Note that "123.456" is approximated with 123.46. Note too that floats have only 6-7 decimal digits of precision and that longer Strings might be truncated. + +[%hardbreaks] + + +[float] +=== Syntax +[source,arduino] +---- +string.toDouble() +---- + +[float] +=== Parameters +`string`: a variable of type String + + +[float] +=== Returns +`double` + +If no valid conversion could be performed because the String doesn't start with a digit, a zero is returned. + +-- +// OVERVIEW SECTION ENDS + + + +// HOW TO USE SECTION ENDS + + +// SEE ALSO SECTION +[#see_also] +-- + +[float] +=== See also + +[role="example"] +* #EXAMPLE# link: https://www.arduino.cc/en/Tutorial/BuiltInExamples#strings[Built-in String Tutorials] +-- +// SEE ALSO SECTION ENDS diff --git a/Language/Variables/Data Types/stringObject.adoc b/Language/Variables/Data Types/stringObject.adoc index 4fb6df6c2..6c2157b93 100644 --- a/Language/Variables/Data Types/stringObject.adoc +++ b/Language/Variables/Data Types/stringObject.adoc @@ -123,6 +123,7 @@ String stringOne = String(5.698, 3); // using a float and t * #LANGUAGE# link:../string/functions/startswith[startsWith()] * #LANGUAGE# link:../string/functions/substring[substring()] * #LANGUAGE# link:../string/functions/tochararray[toCharArray()] +* #LANGUAGE# link:../string/functions/todouble[toDouble()] * #LANGUAGE# link:../string/functions/toint[toInt()] * #LANGUAGE# link:../string/functions/tofloat[toFloat()] * #LANGUAGE# link:../string/functions/tolowercase[toLowerCase()]