The strtod function converts the initial portion of the string pointed to by nptr to double representation. First it decomposes the string into three parts: an initial, possibly empty, sequence of white space characters (as specified by the isspace function), a subject sequence resembling a floating point constant: and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then it attempts to convert the subject sequence to a floating point number, and return the result.
The expected form of the subject sequence is an optional plus or minus sign, then a non-empty sequence of digits optionally containing a decimal-point character, then an optional exponent part as defined in the ANSI specification refsection 6.1.3.1, but no floating suffix. The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists of entirely white space, or if the first non-white space character is other than a sign, a digit or a decimal point.
The strtod function returns the converted value, if any. If no conversion could be performed, zero is returned. If the correct value is outside the range of representable values, plus of minus HUGE_VAL is returned (according to the sign of the value), and the value of the macros ERANGE is stored in errno. If the correct value would cause underflow, zero is returned and the value of the macro ERANGE is store in errno.
In GCC-1750, the accuracy of the result is generally better than 10 digits. In most cases, 13 decimal digits is sufficient to represent any of the 2**48 values of the M1750 extended precision floating point format. Powers of 10 within the range of the M1750 extended precision format (roughly 1.0e-38 to 1.0e+38) are converted exactly. |