This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: printf("%.0f", 0.5) and round-to-even
- From: Eric Blake <ebb9 at byu dot net>
- To: newlib at sources dot redhat dot com
- Date: Mon, 29 Sep 2008 22:06:18 +0000 (UTC)
- Subject: Re: printf("%.0f", 0.5) and round-to-even
- References: <loom.20080929T214200-457@post.gmane.org>
Eric Blake <ebb9 <at> byu.net> writes:
>
> Based on a report on bug-gnu-utils:
> http://lists.gnu.org/archive/html/bug-gnu-utils/2008-09/msg00055.html
> It looks like the printf family could use a QoI improvement when dealing with
> IEEE round-to-even rules. I'll try and look at making this improvement in
the
> next few days.
>
> glibc newlib
> printf("%.0f",0.5) 0 1
> printf("%.0f",1.5) 2 1
> printf("%.0f",2.5) 2 2
> printf("%.0f",3.5) 4 3
>
Other formats are also impacted (although my guess is that fixing it for %f
will also fix %e and %g, and %a should be easy to fix as well.):
printf("%.0e,0.25) 2e-01 2e-01
printf("%.0e,0.75) 8e-01 7e-01
--
Eric Blake