1 /* Copyright (C) 1994 DJ Delorie, see COPYING.DJ for details */
2 #include <crtdll/stdlib.h>
3 #include <crtdll/ctype.h>
4 //#include <crtdll/unconst.h>
6 static double powten[] =
8 1e1L, 1e2L, 1e4L, 1e8L, 1e16L, 1e32L, 1e64L, 1e128L, 1e256L
9 1e512L, 1e512L*1e512L, 1e2048L, 1e4096L
13 _strtold(const char *s, char **sret)
15 double r; /* result */
16 int e, ne; /* exponent */
17 int sign; /* +- 1.0 */
27 while(*s && isspace(*s))
38 while ((*s >= '0') && (*s <= '9'))
49 while ((*s >= '0') && (*s <= '9'))
65 if ((*s == 'e') || (*s == 'E'))
75 while ((*s >= '0') && (*s <= '9'))
90 /* possibly subnormal number, 10^e would overflow */
108 d *= powten[l2powm1];