This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: printf("%.0f", 0.5) and round-to-even


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]