strtodec.3c (2010 09)
s
strtodec(3C)
Itanium(R)-based Systems Only
strtodec(3C)
NAME
strtodec: strtod32(), strtod64(), strtod128() - convert string to decimal floating-point number
SYNOPSIS
#include <strtodec.h>
#include <math.h>
_Decimal32 strtod32 (const char * restrict str, char ** restrict ptr);
_Decimal64 strtod64 (const char * restrict str, char ** restrict ptr);
_Decimal128 strtod128(const char * restrict str, char ** restrict ptr);
DESCRIPTION
The strtod32(), strtod64(), and strtod128() functions convert the initial portion of the string
pointed to by str to _Decimal32, _Decimal64
, and _Decimal128 representation, respectively. The
string is scanned (leading white-space characters as defined by
isspace() are ignored) up to the first
unrecognized character. If no conversion can take place, zero is returned. See ctype (3C) for information
about
isspace().
strtod32(), strtod64(), and strtod128() recognize characters in the following sequence:
1. An optional string of white space characters which are ignored
2. An optional sign
and one of the following:
3. A string of digits optionally containing a radix character, followed by an optional
e or
E, fol-
lowed by an optional sign or space, followed by an integer
4. One of
INF or INFINITY, ignoring case
5.
NAN or NAN(d-char-sequence)
, ignoring case in the NAN part, where d-char-
sequence is:
"digit"
"d-char-sequence" digit
The radix character is determined by the loaded
NLS environment (see setlocale (3C)). If setlo-
cale() has not been called successfully, the default
NLS environment, "C", is used (see lang (5)).
The default environment specifies a period (
.) as the radix character.
If the value of ptr is not
(char **)NULL, the variable to which it points is set to point at the char-
acter after the last number, if any, that was recognized. If no number can be formed,
*ptr is set to
str , and zero is returned.
EXTERNAL INFLUENCES
Environment Variables
LC_NUMERIC determines the value of the radix character within the currently loaded NLS environment.
RETURN VALUE
The functions return the converted value, if any. If no conversion could be performed, the value
+0.E0
is returned. If the correct value is outside the range of representable values, plus or minus
HUGE_VAL_D32, HUGE_VAL_D64,orHUGE_VAL_D128 is returned (according to the return type and
sign of the value), and the value of the macro [ERANGE] is stored in errno. If the result underflows,
the functions return a value whose magnitude is no greater than the smallest normalized positive number
in the return type.
SEE ALSO
ctype(3C), setlocale(3C), strtod(3C), lang(5).
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1