NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
float strtod ( const string &  str,
string &  endptr 

Convert string to float.

Parses the string str interpreting its content as a floating point number and returns its value as a float.

The function first discards as many whitespace characters as necessary until the first non-whitespace character is found. Then, starting from this character, takes as many characters as possible that are valid following a syntax resembling that of floating point literals, and interprets them as a numerical value. A string containing the rest of the string after the last valid character is stored in endptr.

A valid floating point number for atof is formed by a succession of:

  • An optional plus or minus sign
  • A sequence of digits, optionally containing a decimal-point character
  • An optional exponent part, which itself consists on an 'e' or 'E' character followed by an optional sign and a sequence of digits.

If the first sequence of non-whitespace characters in str does not form a valid floating-point number as just defined, or if no such sequence exists because either str is empty or contains only whitespace characters, no conversion is performed.

strString beginning with the representation of a floating-point number.
endptrReference to a string, whose value is set by the function to the remaining characters in str after the numerical value.
On success, the function returns the converted floating point number as a float value. If no valid conversion could be performed a zero value (0.0) is returned.