summaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-11-19 23:26:56 +0000
committerUlrich Drepper <drepper@redhat.com>1997-11-19 23:26:56 +0000
commit5e38f61608018b713833c6c78c351711cc3fc528 (patch)
tree51b92ceede2d0dbb9b5ef5e6904fa45edb3bc094 /stdlib
parenta49d90cee989f9606918b086555b0b26b57692ef (diff)
Handle input like 0.0e1000 correctly.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/strtod.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index 7907dedde3..7398898abc 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)
{