From: Ulrich Drepper Date: Wed, 19 Nov 1997 23:26:56 +0000 (+0000) Subject: Handle input like 0.0e1000 correctly. X-Git-Tag: cvs/glibc-2_0_6-pre2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e38f61608018b713833c6c78c351711cc3fc528;p=thirdparty%2Fglibc.git Handle input like 0.0e1000 correctly. --- diff --git a/stdlib/strtod.c b/stdlib/strtod.c index 7907dedde33..7398898abc2 100644 --- a/stdlib/strtod.c +++ b/stdlib/strtod.c @@ -562,10 +562,18 @@ INTERNAL (STRTOF) (nptr, endptr, group) { FLOAT retval; - /* Overflow or underflow. */ - __set_errno (ERANGE); - retval = (exp_negative ? 0.0 : - negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL); + /* We have to take care for special situation: a joker + might have written "0.0e100000" which is in fact + zero. */ + if (lead_zero == -1) + retval = !negative ? 0.0 : -0.0; + else + { + /* Overflow or underflow. */ + __set_errno (ERANGE); + retval = (exp_negative ? 0.0 : + negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL); + } /* Accept all following digits as part of the exponent. */ do @@ -606,7 +614,7 @@ INTERNAL (STRTOF) (nptr, endptr, group) *endptr = (STRING_TYPE *) cp; if (dig_no == 0) - return 0.0; + return !negative ? 0.0 : -0.0; if (lead_zero) {