Update contrib.
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
15 // <<atof>>, <<atoff>>---string to double or float
23 // #include <stdlib.h>
24 // double atof(const char *<[s]>);
25 // float atoff(const char *<[s]>);
27 // #include <stdlib.h>
32 // <<atof>> converts the initial portion of a string to a <<double>>.
33 // <<atoff>> converts the initial portion of a string to a <<float>>.
34 // The functions parse the character string <[s]>,
35 // locating a substring which can be converted to a floating point
36 // value. The substring must match the format:
37 // . [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
38 // The substring converted is the longest initial
39 // fragment of <[s]> that has the expected format, beginning with
40 // the first non-whitespace character. The substring
41 // is empty if <<str>> is empty, consists entirely
42 // of whitespace, or if the first non-whitespace character is
43 // something other than <<+>>, <<->>, <<.>>, or a digit.
44 // <<atof(<[s]>)>> is implemented as <<strtod(<[s]>, NULL)>>.
45 // <<atoff(<[s]>)>> is implemented as <<strtodf(<[s]>, NULL)>>.
47 // <<atof>> returns the converted substring value, if any, as a
48 // <<double>>; or <<0.0>>, if no conversion could be performed.
49 // If the correct value is out of the range of representable values, plus
50 // or minus <<HUGE_VAL>> is returned, and <<ERANGE>> is stored in
52 // If the correct value would cause underflow, <<0.0>> is returned
53 // and <<ERANGE>> is stored in <<errno>>.
54 // <<atoff>> obeys the same rules as <<atof>>, except that it
55 // returns a <<float>>.
57 // <<atof>> is ANSI C. <<atof>>, <<atoi>>, and <<atol>> are subsumed by <<strtod>>
58 // and <<strtol>>, but are used extensively in existing code. These functions are
59 // less reliable, but may be faster if the argument is verified to be in a valid
61 // Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
62 // <<lseek>>, <<read>>, <<sbrk>>, <<write>>.
69 #include "../INC/ESTLIB.H"
73 Convert string to double-precision floating-point value.
74 Parses string interpreting its content as a floating-point value
75 until a character that can not be interpreted is found,
76 and returns a double precision value.
77 @return The converted double value from the input string.
78 If an error occurs 0 is returned.
79 @param s String representing a floating point number.
80 @param tail Address of a pointer.
81 This is filled by the function with the address where scan has ended.
82 Serves to determine where there is the first non-numerical character in the string.
84 EXPORT_C double strtod (const char *s, char** tail) __SOFTFP
86 TLex8 data=(unsigned char *)s;
89 TBool minus = data.Peek() == '-';
99 else if (r==KErrUnderflow)
102 *tail=(char*)(s+data.Offset());
107 Convert string to double.
108 Parses string interpreting its content as a floating point number
109 and returns a value of type double.
110 @return The converted floating point value of the input string.
111 On overflow the result is undefined.
112 If an error occurs 0.0 is returned.
113 @param s String representing a floating point number.
115 EXPORT_C double atof (const char *s) __SOFTFP
117 return strtod(s,NULL);