Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 8
Convert a string into a double
#include <stdlib.h>
double strtod( const char *ptr,
char **endptr );
- ptr
- A pointer to the string to parse.
- endptr
- If this argument isn't NULL, the function stores in it a
pointer to the first unrecognized character found in the string.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The strtod() function converts the string pointed to by
ptr to double representation. The function recognizes a
string containing the following:
- optional white space
- an optional plus or minus sign
- a sequence of digits containing an optional decimal point
- an optional e or E, followed by an optionally
signed sequence of digits.
The conversion ends at the first unrecognized character.
If endptr isn't NULL, a pointer to the unrecognized
character is stored in the object endptr points to.
The converted value.
If the correct value would cause overflow, plus or minus
HUGE_VAL is returned according to the sign, and
errno
is set to ERANGE.
If the correct value would cause underflow, then zero is returned, and
errno is set to ERANGE.
This function returns zero when the input string can't be converted.
If an error occurs, errno indicates the error detected.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
double pi;
pi = strtod( "3.141592653589793", NULL );
printf( "pi=%17.15f\n",pi );
return EXIT_SUCCESS;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
Yes |
Thread |
Yes |
atof(),
errno
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 157
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/strtod.html on line 157