From 5e38f61608018b713833c6c78c351711cc3fc528 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Wed, 19 Nov 1997 23:26:56 +0000 Subject: [PATCH] Handle input like 0.0e1000 correctly. --- stdlib/strtod.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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) { -- 2.47.2