[adding bug-gnulib]

On 01/11/2011 08:40 PM, Andrew J. Schorr wrote:
> On Tue, Jan 11, 2011 at 10:31:26PM -0500, Andrew J. Schorr wrote:
>> Using gawk 3.1.8 on Fedora 13 64-bit linux, I see this:
>>
>> bash-4.1$ (echo 1000000; echo 999999.9998071828) | gawk -v "sq='" '{printf 
>> "%" sq ".2f\n", $1}'
>> 1,000,000.00
>> ,000,000.00
> 
> Actually, this may be a glibc bug:
> 
> bash-4.1$ printf "%'.2f\n" 999999.9998071828
> ,000,000.00
> 
> bash-4.1$ printf "%'.2f\n" 1000000
> 1,000,000.00

> bash-4.1$ rpm -q glibc
> glibc-2.12.1-4.x86_64

I concur, as running the same tests on both Solaris 10 and on Cygwin
1.7.7 under LC_ALL=en_US produced correct results.

It appears that glibc fails to account for the fact that rounding may
increase the number of result characters by 2 instead of 1 when %' is in
effect (going from 999 to 1,000, at any power of 10*3).

Please file a glibc bug, and in the meantime, gnulib should consider
modifying the printf-posix family of modules to work around this
rounding bug.

-- 
Eric Blake   ebl...@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to