about summary refs log tree commit diff
path: root/stdlib/strtod.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/strtod.c')
-rw-r--r--stdlib/strtod.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/stdlib/strtod.c b/stdlib/strtod.c
index d35dc2d5ac..cd78ef0df4 100644
--- a/stdlib/strtod.c
+++ b/stdlib/strtod.c
@@ -712,10 +712,18 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
 		{
 	 	  FLOAT result;
 
-		  /* Overflow or underflow.  */
-		  __set_errno (ERANGE);
-		  result = (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)
+		    result = negative ? -0.0 : 0.0;
+		  else
+		    {
+		      /* Overflow or underflow.  */
+		      __set_errno (ERANGE);
+		      result = (exp_negative ? 0.0 :
+				negative ? -FLOAT_HUGE_VAL : FLOAT_HUGE_VAL);
+		    }
 
 		  /* Accept all following digits as part of the exponent.  */
 		  do
@@ -756,7 +764,7 @@ INTERNAL (STRTOF) (nptr, endptr, group LOCALE_PARAM)
     *endptr = (STRING_TYPE *) cp;
 
   if (dig_no == 0)
-    return 0.0;
+    return negative ? -0.0 : 0.0;
 
   if (lead_zero)
     {