*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Tru64 Unix man pages -> strtof (3)              
Title
Content
Arch
Section
 

atof(3)

Contents


NAME    [Toc]    [Back]

       atof,  strtod,  strtof,  strtold  -  Converts  a character
       string to a double-precision floating-point value

SYNOPSIS    [Toc]    [Back]

       #include <stdlib.h>

       double atof(
               const char *nptr ); double strtod(
               const char *nptr,
               char **endptr ); float strtof(
               const char *nptr,
               char **endptr ); long double strtold(
               const char *nptr,
               char **endptr );

LIBRARY    [Toc]    [Back]

       Standard C Library (libc)

PARAMETERS    [Toc]    [Back]

       Points to the  character  string  to  convert.   Specifies
       either a null value, a pointer to the character that ended
       the scan, or a pointer to a null value.

DESCRIPTION    [Toc]    [Back]

       The atof() function converts, to a  double  floating-point
       value, the string pointed to by the nptr parameter - up to
       the first character that is inconsistent with  the  format
       of  a  floating-point number. Leading space characters are
       ignored. A call to this function is equivalent to  a  call
       to  strtod(nptr,  (char  **)  NULL), except for error handling.
 When the value cannot be represented, the result is
       undefined.

       The  strtod(),  strtof(),  and strtold() functions convert
       the initial portion of the string pointed to by  the  nptr
       parameter  to  double,  float, and long double representation,
 respectively.  First, the input string is decomposed
       into  the  following  three  parts:  An  initial, possibly
       empty, sequence of space characters (as specified  by  the
       isspace()  function).  A subject sequence interpreted as a
       floating-point constant.  A final string of  one  or  more
       unrecognized  characters,  including  the terminating null
       character of the input string.

       After decomposition of the string, the subject sequence is
       converted  to  a  floating-point  number and the resulting
       value is returned. A subject sequence is  defined  as  the
       longest  initial subsequence of the input string, starting
       with  the  first  non-space  character,  that  is  of  the
       expected form.  The expected form and order of the subject
       sequence is: An optional plus (+) or minus  (-)  sign.   A
       sequence  of  digits optionally containing a radix character.
  An optional exponent part. An exponent part consists
       of e or E, followed by an optional sign, which is followed
       by one or more decimal digits.

       The subject sequence contains no characters when the input
       string  is empty or consists entirely of space characters,
       or when the first non-space  character  is  other  than  a
       sign, a digit, or a radix character.

       For  the strtod(), strtof(), and strtold() functions, when
       the value of the endptr parameter is not (char**) NULL,  a
       pointer  to  the  character  that  terminated  the scan is
       stored at *endptr.

       When a floating-point value cannot be formed,  *endptr  is
       set to nptr.

       The  strings  NaN ("not a number"), Inf, and Infinity (the
       case of the characters does not matter) are recognized  as
       valid  only  when  the  program is compiled with the -ieee
       option.

NOTES    [Toc]    [Back]

       The setlocale() function may affect  the  radix  character
       used in the conversion result.  Full use

RETURN VALUES    [Toc]    [Back]

       When  the  string  is empty or begins with an unrecognized
       character, +0.0 is returned as the floating-point value.

       If the calling routine  is  compiled  with  IEEE  floating
       point  enabled (-ieee option), errno will be set to ERANGE
       if the conversion underflows to zero.  Similarly,  if  the
       value  overflows, ERANGE will be set and a properly signed
       infinity will be returned.

       If the calling routine is not compiled with IEEE  floating
       point enabled, any underflow will cause errno to be set to
       ERANGE and a properly signed zero to be returned. An overflow
  will cause errno to be set to ERANGE and will return
       a properly signed DBL_MAX, FLOAT_MAX, or LDBL_MAX.

       Upon successful completion, all of  the  functions  return
       the converted floating-point value.

ERRORS    [Toc]    [Back]

       If  the  atof(), strtod(), strtof(), or strtold() function
       fails, errno may be set to the following value: The  input
       string is out of range (that is, the subject sequence cannot
 be converted to a floating-point value without causing
       underflow or overflow).

SEE ALSO    [Toc]    [Back]

      
      
       Functions: atoi(3), scanf(3)



                                                          atof(3)
[ Back ]
 Similar pages
Name OS Title
mbrtowc NetBSD converts a multibyte character to a wide character (restartable)
wcrtomb NetBSD converts a wide character to a multibyte character (restartable)
wctomb NetBSD converts a wide character to a multibyte character
mbtowc NetBSD converts a multibyte character to a wide character
uscctc IRIX Converts EBCDIC character data to ASCII character data, and vice versa
mbsrtowcs NetBSD converts a multibyte character string to a wide character string (restartable)
wcsrtombs NetBSD converts a wide character string to a multibyte character string (restartable)
strptime NetBSD converts a character string to a time value
strptime OpenBSD converts a character string to a time value
mbstowcs NetBSD converts a multibyte character string to a wide character string
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service