Skip to content

Commit 87a3a67

Browse files
authored
Merge pull request #484 from per1234/todouble
Document String.toDouble()
2 parents 6feeb88 + bd355a6 commit 87a3a67

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: "toDouble()"
3+
categories: [ "Data Types" ]
4+
subCategories: [ "StringObject Function" ]
5+
---
6+
7+
8+
9+
10+
11+
= toDouble()
12+
13+
14+
// OVERVIEW SECTION STARTS
15+
[#overview]
16+
--
17+
18+
[float]
19+
=== Description
20+
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.
21+
22+
[%hardbreaks]
23+
24+
25+
[float]
26+
=== Syntax
27+
[source,arduino]
28+
----
29+
string.toDouble()
30+
----
31+
32+
[float]
33+
=== Parameters
34+
`string`: a variable of type String
35+
36+
37+
[float]
38+
=== Returns
39+
`double`
40+
41+
If no valid conversion could be performed because the String doesn't start with a digit, a zero is returned.
42+
43+
--
44+
// OVERVIEW SECTION ENDS
45+
46+
47+
48+
// HOW TO USE SECTION ENDS
49+
50+
51+
// SEE ALSO SECTION
52+
[#see_also]
53+
--
54+
55+
[float]
56+
=== See also
57+
58+
[role="example"]
59+
* #EXAMPLE# link: https://www.arduino.cc/en/Tutorial/BuiltInExamples#strings[Built-in String Tutorials]
60+
--
61+
// SEE ALSO SECTION ENDS

Language/Variables/Data Types/stringObject.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ String stringOne = String(5.698, 3); // using a float and t
123123
* #LANGUAGE# link:../string/functions/startswith[startsWith()]
124124
* #LANGUAGE# link:../string/functions/substring[substring()]
125125
* #LANGUAGE# link:../string/functions/tochararray[toCharArray()]
126+
* #LANGUAGE# link:../string/functions/todouble[toDouble()]
126127
* #LANGUAGE# link:../string/functions/toint[toInt()]
127128
* #LANGUAGE# link:../string/functions/tofloat[toFloat()]
128129
* #LANGUAGE# link:../string/functions/tolowercase[toLowerCase()]

0 commit comments

Comments
 (0)