OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdlib/] [atof.c] - Diff between revs 1010 and 1765

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 1010 Rev 1765
/*
/*
FUNCTION
FUNCTION
   <<atof>>, <<atoff>>---string to double or float
   <<atof>>, <<atoff>>---string to double or float
 
 
INDEX
INDEX
        atof
        atof
INDEX
INDEX
        atoff
        atoff
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        double atof(const char *<[s]>);
        double atof(const char *<[s]>);
        float atoff(const char *<[s]>);
        float atoff(const char *<[s]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <stdlib.h>
        #include <stdlib.h>
        double atof(<[s]>)
        double atof(<[s]>)
        char *<[s]>;
        char *<[s]>;
 
 
        float atoff(<[s]>)
        float atoff(<[s]>)
        char *<[s]>;
        char *<[s]>;
 
 
DESCRIPTION
DESCRIPTION
<<atof>> converts the initial portion of a string to a <<double>>.
<<atof>> converts the initial portion of a string to a <<double>>.
<<atoff>> converts the initial portion of a string to a <<float>>.
<<atoff>> converts the initial portion of a string to a <<float>>.
 
 
The functions parse the character string <[s]>,
The functions parse the character string <[s]>,
locating a substring which can be converted to a floating point
locating a substring which can be converted to a floating point
value. The substring must match the format:
value. The substring must match the format:
. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
The substring converted is the longest initial
The substring converted is the longest initial
fragment of <[s]> that has the expected format, beginning with
fragment of <[s]> that has the expected format, beginning with
the first non-whitespace character.  The substring
the first non-whitespace character.  The substring
is empty if <<str>> is empty, consists entirely
is empty if <<str>> is empty, consists entirely
of whitespace, or if the first non-whitespace character is
of whitespace, or if the first non-whitespace character is
something other than <<+>>, <<->>, <<.>>, or a digit.
something other than <<+>>, <<->>, <<.>>, or a digit.
 
 
<<atof(<[s]>)>> is implemented as <<strtod(<[s]>, NULL)>>.
<<atof(<[s]>)>> is implemented as <<strtod(<[s]>, NULL)>>.
<<atoff(<[s]>)>> is implemented as <<strtodf(<[s]>, NULL)>>.
<<atoff(<[s]>)>> is implemented as <<strtodf(<[s]>, NULL)>>.
 
 
RETURNS
RETURNS
<<atof>> returns the converted substring value, if any, as a
<<atof>> returns the converted substring value, if any, as a
<<double>>; or <<0.0>>,  if no conversion could be performed.
<<double>>; or <<0.0>>,  if no conversion could be performed.
If the correct value is out of the range of representable values, plus
If the correct value is out of the range of representable values, plus
or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is stored in
or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is stored in
<<errno>>.
<<errno>>.
If the correct value would cause underflow, <<0.0>> is returned
If the correct value would cause underflow, <<0.0>> is returned
and <<ERANGE>> is stored in <<errno>>.
and <<ERANGE>> is stored in <<errno>>.
 
 
<<atoff>> obeys the same rules as <<atof>>, except that it
<<atoff>> obeys the same rules as <<atof>>, except that it
returns a <<float>>.
returns a <<float>>.
 
 
PORTABILITY
PORTABILITY
<<atof>> is ANSI C. <<atof>>, <<atoi>>, and <<atol>> are subsumed by <<strod>>
<<atof>> is ANSI C. <<atof>>, <<atoi>>, and <<atol>> are subsumed by <<strod>>
and <<strol>>, but are used extensively in existing code. These functions are
and <<strol>>, but are used extensively in existing code. These functions are
less reliable, but may be faster if the argument is verified to be in a valid
less reliable, but may be faster if the argument is verified to be in a valid
range.
range.
 
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
*/
 
 
 
 
#include <stdlib.h>
#include <stdlib.h>
#include <_ansi.h>
#include <_ansi.h>
 
 
double
double
_DEFUN (atof, (s),
_DEFUN (atof, (s),
        _CONST char *s)
        _CONST char *s)
{
{
  return strtod (s, NULL);
  return strtod (s, NULL);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.