From 8a0efa53e44919bcf5ccb1d3353618a82afdf8bc Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:39:52 +0000 Subject: import newlib-2000-02-17 snapshot --- newlib/libc/stdlib/atof.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 newlib/libc/stdlib/atof.c (limited to 'newlib/libc/stdlib/atof.c') diff --git a/newlib/libc/stdlib/atof.c b/newlib/libc/stdlib/atof.c new file mode 100644 index 000000000..cf4abdb71 --- /dev/null +++ b/newlib/libc/stdlib/atof.c @@ -0,0 +1,72 @@ +/* +FUNCTION + <>, <>---string to double or float + +INDEX + atof +INDEX + atoff + +ANSI_SYNOPSIS + #include + double atof(const char *<[s]>); + float atoff(const char *<[s]>); + +TRAD_SYNOPSIS + #include + double atof(<[s]>) + char *<[s]>; + + float atoff(<[s]>) + char *<[s]>; + +DESCRIPTION +<> converts the initial portion of a string to a <>. +<> converts the initial portion of a string to a <>. + +The functions parse the character string <[s]>, +locating a substring which can be converted to a floating point +value. The substring must match the format: +. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>] +The substring converted is the longest initial +fragment of <[s]> that has the expected format, beginning with +the first non-whitespace character. The substring +is empty if <> is empty, consists entirely +of whitespace, or if the first non-whitespace character is +something other than <<+>>, <<->>, <<.>>, or a digit. + +<)>> is implemented as <, NULL)>>. +<)>> is implemented as <, NULL)>>. + +RETURNS +<> returns the converted substring value, if any, as a +<>; or <<0.0>>, if no conversion could be performed. +If the correct value is out of the range of representable values, plus +or minus <> is returned, and <> is stored in +<>. +If the correct value would cause underflow, <<0.0>> is returned +and <> is stored in <>. + +<> obeys the same rules as <>, except that it +returns a <>. + +PORTABILITY +<> is ANSI C. <>, <>, and <> are subsumed by <> +and <>, 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 +range. + +Supporting OS subroutines required: <>, <>, <>, +<>, <>, <>, <>. +*/ + + +#include +#include <_ansi.h> + +double +_DEFUN (atof, (s), + _CONST char *s) +{ + return strtod (s, NULL); +} -- cgit v1.2.3