Library /sys$common/syshlp/helplib.hlb  —  CRTL  strtod
    Converts a given string to a double-precision number.

    Format

      #include  <stdlib.h>

      double strtod  (const char *nptr, char **endptr);

1  –  Function Variants

    The strtod function has variants named _strtod32 and _strtod64
    for use with 32-bit and 64-bit pointer sizes, respectively.

2  –  Arguments

 nptr

    A pointer to the character string to be converted to a double-
    precision number.

 endptr

    The address of an object where the function can store the address
    of the first unrecognized character that terminates the scan. If
    endptr is a NULL pointer, the address of the first unrecognized
    character is not retained.

3  –  Description

    The strtod function recognizes an optional sequence of white-
    space characters (as defined by isspace), then an optional plus
    or minus sign, then a sequence of digits optionally containing a
    radix character, then an optional letter (e or E) followed by an
    optionally signed integer. The first unrecognized character ends
    the conversion.

    The string is interpreted by the same rules used to interpret
    floating constants.

    The radix character is defined the program's current locale
    (category LC_NUMERIC).

    This function returns the converted value. For strtod, overflows
    are accounted for in the following manner:

    o  If the correct value causes an overflow, HUGE_VAL (with a plus
       or minus sign according to the sign of the value) is returned
       and errno is set to ERANGE.

    o  If the correct value causes an underflow, 0 is returned and
       errno is set to ERANGE.

    If the string starts with an unrecognized character, then the
    conversion is not performed, *endptr is set to nptr, a 0 value is
    returned, and errno is set to EINVAL.)

4  –  Return Values

    x                  The converted string.
    0                  Indicates the conversion could not be
                       performed. errno is set to one of the
                       following:

                       o  EINVAL - No conversion could be performed.

                       o  ERANGE - The value would cause an
                          underflow.

                       o  ENOMEM - Not enough memory available for
                          internal conversion buffer.

    HUGE_VAL           Overflow occurred; errno is set to ERANGE.
Close Help