toDouble()

[StringObject Function]

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.

Syntax

myString.toDouble()

Parameters

myString: a variable of type String.

Returns

If no valid conversion could be performed because the String doesn’t start with a digit, a zero is returned. Data type: double.

See also

  • Language c_str()

  • Language charAt()

  • Language compareTo()

  • Language concat()

  • Language endsWith()

  • Language equals()

  • Language equalsIgnoreCase()

  • Language getBytes()

  • Language indexOf()

  • Language lastIndexOf()

  • Language length()

  • Language remove()

  • Language replace()

  • Language reserve()

  • Language setCharAt()

  • Language startsWith()

  • Language substring()

  • Language toCharArray()

  • Language toFloat()

  • Language toInt()

  • Language toLowerCase()

  • Language toUpperCase()

  • Language trim()