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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libc/] [stdlib/] [atof.c] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/*
2
FUNCTION
3
   <<atof>>, <<atoff>>---string to double or float
4
 
5
INDEX
6
        atof
7
INDEX
8
        atoff
9
 
10
ANSI_SYNOPSIS
11
        #include <stdlib.h>
12
        double atof(const char *<[s]>);
13
        float atoff(const char *<[s]>);
14
 
15
TRAD_SYNOPSIS
16
        #include <stdlib.h>
17
        double atof(<[s]>)
18
        char *<[s]>;
19
 
20
        float atoff(<[s]>)
21
        char *<[s]>;
22
 
23
DESCRIPTION
24
<<atof>> converts the initial portion of a string to a <<double>>.
25
<<atoff>> converts the initial portion of a string to a <<float>>.
26
 
27
The functions parse the character string <[s]>,
28
locating a substring which can be converted to a floating-point
29
value. The substring must match the format:
30
. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
31
The substring converted is the longest initial
32
fragment of <[s]> that has the expected format, beginning with
33
the first non-whitespace character.  The substring
34
is empty if <<str>> is empty, consists entirely
35
of whitespace, or if the first non-whitespace character is
36
something other than <<+>>, <<->>, <<.>>, or a digit.
37
 
38
<<atof(<[s]>)>> is implemented as <<strtod(<[s]>, NULL)>>.
39
<<atoff(<[s]>)>> is implemented as <<strtof(<[s]>, NULL)>>.
40
 
41
RETURNS
42
<<atof>> returns the converted substring value, if any, as a
43
<<double>>; or <<0.0>>,  if no conversion could be performed.
44
If the correct value is out of the range of representable values, plus
45
or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is stored in
46
<<errno>>.
47
If the correct value would cause underflow, <<0.0>> is returned
48
and <<ERANGE>> is stored in <<errno>>.
49
 
50
<<atoff>> obeys the same rules as <<atof>>, except that it
51
returns a <<float>>.
52
 
53
PORTABILITY
54
<<atof>> is ANSI C. <<atof>>, <<atoi>>, and <<atol>> are subsumed by <<strod>>
55
and <<strol>>, but are used extensively in existing code. These functions are
56
less reliable, but may be faster if the argument is verified to be in a valid
57
range.
58
 
59
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
60
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
61
*/
62
 
63
 
64
#include <stdlib.h>
65
#include <_ansi.h>
66
 
67
double
68
_DEFUN (atof, (s),
69
        _CONST char *s)
70
{
71
  return strtod (s, NULL);
72
}

powered by: WebSVN 2.1.0

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