diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-03-06 20:00:13 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-03-06 20:00:13 -0500 |
commit | 7039de6a6731437647bf6f1c3b480766872ac077 (patch) | |
tree | 91b046242226997677af0e9ec64522e8a80caf68 /src/stdlib/strtold.c | |
parent | 813c3440d19d8bbbe8987013d9d7160454327faf (diff) |
begin work on a common string-to-floating-point implementation
Diffstat (limited to 'src/stdlib/strtold.c')
-rw-r--r-- | src/stdlib/strtold.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/stdlib/strtold.c b/src/stdlib/strtold.c index eeb0b8b0..eb19fcc0 100644 --- a/src/stdlib/strtold.c +++ b/src/stdlib/strtold.c @@ -1,11 +1,42 @@ #include <stdlib.h> +#include "float.h" +#include "ctype.h" +#include "errno.h" +#include "math.h" + +/** convert string to floating-point **/ long double strtold(const char * restrict nptr, char ** restrict endptr) { - (void)nptr; (void)endptr; - return 0; + long double ret = 0.0; + long double max = LDBL_MAX; + long double min = LDBL_MIN; + long double huge = HUGE_VALL; + long double inf = INFINITY; + long double nan = NAN; + + #include "_strtod.h" + + return ret; } +/*** +converts the string at ARGUMENT(nptr) to a TYPE(double). +Leading whitespace is ignored. The first character that is not a valid character +for a floating-point constant and any characters after it are also ignored. A +pointer to the first invalid character is stored in ARGUMENT(endptr), unless +ARGUMENT(endptr) is CONSTANT(NULL). + +The converted portion of the string may start with an optional plus or minus +sign, followed by a nonempty series of digits, optionally containing a +decimal-point character. This may optionally be followed by an exponent. +***/ + /* +LC_CTYPE +RETURN(ZERO, underflow or no conversion could be performed) +RETURN(CONSTANT(HUGE_VALL), converted value too large) +RETURN(CONSTANT(-HUGE_VALL), converted value too small) +RETURN(VAR(a TYPE(long double)), the converted value) STDC(199901) */ |