C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
strtod, strtol, strtoul, _strtold
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The strtod, strtol, and strtoul functions convert a character
     string to a double-precision value, a long-integer value, and an
     unsigned long-integer value, respectively. The _strtold function
     converts a character string to a double-precision floating-point
     value.
 
     The input string is a sequence of characters that can be
     interpreted as a numerical value of the specified type.
 
     These functions stop reading the string at the first character
     that they cannot recognize as part of a number. This may be the
     null character (\0) at the end of the string. With strtol or
     strtoul, this terminating character can also be the first numeric
     character greater than or equal to <base>. If <endptr> is not the
     null character, it points to the character that stopped the scan.
 
     The strtod and _strtold functions expect <nptr> to point to a
     string with the following form:
 
          [whitespace] [sign] [digits] [.digits] [ { d | D | e | E }
          [sign] digits]
 
     A <whitespace> consists of space and tab characters, which are
     ignored; <sign> is either plus (+) or minus (-); and <digits> are
     one or more decimal digits. If no digits appear before the
     decimal point, at least one must appear after the decimal point.
     The decimal digits can be followed by an exponent, which consists
     of an introductory letter (b, D, e, or E) and an optionally
     signed decimal integer.
 
     The first character that does not fit this form stops the scan.
 
     The strtol function expects <nptr> to point to a string with the
     following form:
 
          [whitespace] [sign] [0] [ { x | X } ] [digits]
 
     The strtoul function expects <nptr> to point to a string having
     this form:
 
          [whitespace] [ { + | ─ } ] [0] [ { x | X } ] [digits]
 
     If <base> is between 2 and 36, it is used as the base of the
     number.
 
     If <base> is 0, the initial characters of the string pointed to by
     <nptr> are used to determine the base. If the first character is 0
     and the second character is not 'x' or 'X', the string is
     interpreted as an octal integer. Otherwise, it is interpreted as
     a decimal number.
 
     If the first character is '0' and the second character is 'x' or
     'X', the string is interpreted as a hexadecimal integer.
 
     If the first character is '1' - '9', the string is interpreted as
     a decimal integer. The letters 'a' through 'z' (or 'A' through 'Z')
     are assigned the values 10 - 35. Only letters whose assigned values
     are less than <base> are permitted.
 
     The strtoul function allows a + (plus) or - (minus) sign prefix; a
     leading minus sign indicates that the return value is negated.
 
     Return Value
 
     The strtod function returns the value of the floating-point
     number, except when the representation would cause an overflow, in
     which case it returns +/- HUGE_VAL. The function returns 0 if no
     conversion can be performed or an underflow occurs.
 
     The strtol function returns the value represented in the string,
     except when the representation would cause an overflow, in which
     case it returns LONG_MAX or LONG_MIN. If no conversion can be
     performed, the function returns 0.
 
     The strtoul function returns the converted value, if any. If no
     conversion can be performed, the function returns 0. The function
     returns ULONG_MAX on overflow.
 
     The _strtold function returns the value of the floating-point
     number, except when the representation would cause an overflow, in
     which case it returns _LHUGE_VAL. The function returns 0 if no
     conversion can be performed or an underflow occurs.
 
     In all four functions, errno is set to ERANGE if an overflow or
     underflow occurs.
                                    -♦-