[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf("%.0f", 0.5) and round-to-even
From: |
Eric Blake |
Subject: |
Re: printf("%.0f", 0.5) and round-to-even |
Date: |
Tue, 30 Sep 2008 06:02:30 -0600 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.17) Gecko/20080914 Thunderbird/2.0.0.17 Mnenhy/0.7.5.666 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Bruno Haible on 9/30/2008 4:43 AM:
> Does glibc do round-to-even here generally (not just in the one special case
> you mentioned?) If so, the module name should be called fprintf-gnu, otherwise
> fprintf-posix-ext.
Both glibc and the gnulib *printf replacement already round to nearest;
and cygwin 1.5.x failed enough other tests that the gnulib replacement was
already selected (as evidenced by the fact that on cygwin, gawk and m4 got
different results, because only m4 uses gnulib's replacements).
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
printf("%.0e,0.25) 2e-01 2e-01
printf("%.0e,0.75) 8e-01 7e-01
I suspect %a is also affected, although in newlib's case, %a goes through
a different code path than %[efg].
- --
Don't work too hard, make some time for fun as well!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkjiFVYACgkQ84KuGfSFAYApUQCgmWpFWJ1x5U7I5fpkwJxY5x7O
0ysAoIvy6ZHZQuI5aoyrP0g7qX/0HrTk
=FdMJ
-----END PGP SIGNATURE-----