strtod.3c (2010 09)

s
strtod(3C) strtod(3C)
NAME
strtod(), strtof(), strtold(), strtow(), strtoq(), atof() - convert string to floating-point number
SYNOPSIS
#include <stdlib.h>
double strtod(const char *__restrict str, char **__restrict ptr);
long double strtold(const char *__restrict str, char **__restrict ptr);
double atof(const char *str);
Itanium(R)-based Systems Only
float strtof(const char *__restrict str, char **__restrict ptr);
extended strtow(const char *str, char **ptr);
quad strtoq(const char *str, char **ptr);
DESCRIPTION
strtod() returns, as a double-precision floating-point number, the value represented by the character
string pointed to by str. The string is scanned (leading white-space characters as defined by
isspace() in ctype (3C) are ignored) up to the first unrecognized character. If no conversion can take
place, zero is returned.
strtod() recognizes 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, ignoring case
6. For Itanium-based system only:
0x or 0X, then a nonempty sequence of hexadecimal digits
optionally containing a radix character, then a
p or P, followed by an optional sign or space,
followed by a decimal integer
The radix character is determined by the loaded
NLS environment (see setlocale (3C)). If setlocale()
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.
In the hexadecimal form, the optionally signed decimal integer following the
p or P is interpreted as the
power of 2 by which the significant part is to be scaled.
If the value of ptr is not
(char **)NULL, the variable to which it points is set to point at the character
after the last number, if any, that was recognized. If no number can be formed, *ptr is set to str, and
zero is returned.
atof(str) is equivalent to strtod (str, (char **)NULL).
strtold() is a long double version of strtod(); it returns a long double result. For PA-
RISC and for Itanium-based systems, if the user has defined _LONG_DOUBLE_STRUCT
, the result type
is declared as a
struct, instead of as a long double. The declaration with a struct is obsolescent.
Itanium-based Systems Only
strtof() is a float version of strtod(); it returns a float result.
strtow() is an extended version of strtod(); it returns an extended result.
strtoq() is equivalent to strtold().
EXTERNAL INFLUENCES
Environment Variables
LC_NUMERIC determines the value of the radix character within the currently loaded NLS environment.
APPLICATION USAGE
To use (for Itanium-based systems)
strtow() or strtoq(), compile with the -fpwidetypes option.
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (2 pages)