OSDN Git Service

2008-10-06 Eric Blake <ebb9@byu.net>
authorjjohnstn <jjohnstn>
Mon, 6 Oct 2008 19:47:06 +0000 (19:47 +0000)
committerjjohnstn <jjohnstn>
Mon, 6 Oct 2008 19:47:06 +0000 (19:47 +0000)
        * libc/stdlib/ldtoa.c (etoasc): Fix rounding to even when fraction
        is 0.5 or 0.75.

newlib/ChangeLog
newlib/libc/stdlib/ldtoa.c

index c7e946f..cd00176 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-06  Eric Blake  <ebb9@byu.net>
+
+       * libc/stdlib/ldtoa.c (etoasc): Fix rounding to even when fraction
+       is 0.5 or 0.75.
+
 2008-10-06  Craig Howland  <howland@LGSInnovations.com>
 
        * libc/time/tzset_r.c (_tzset_r):  Change US default start/end dates to
index bb12f0c..5c29725 100644 (file)
@@ -3153,7 +3153,7 @@ if( digit > 4 )
                emovo( y, t, ldp );
                if( ecmp(t,ezero) != 0 )
                        goto roun;      /* round to nearest */
-               if( (*(s-1) & 1) == 0 )
+               if( ndigs < 0 || (*(s-1-(*(s-1)=='.')) & 1) == 0 )
                        goto doexp;     /* round to even */
                }
 /* Round up and propagate carry-outs */