source: trunk/libs/newlib/src/newlib/libc/stdlib/atof.c @ 577

Last change on this file since 577 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

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