bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gawk round-up 0.5 bug?


From: Eric Blake
Subject: Re: gawk round-up 0.5 bug?
Date: Mon, 29 Sep 2008 14:29:56 -0700 (PDT)

> It clearly depends upon the C library, since gawk uses the C library's
> sprintf to do the actual formatting. On my Linux system:
> 
> $ gawk 'BEGIN { printf ("%.0f\n", 0.5) }'
> 0
> $ gawk --version | head -1
> GNU Awk 3.1.6
> $ uname -a
> Linux aahz 2.6.23.14-64.fc7 #1 SMP Sun Jan 20 23:54:08 EST 2008 i686 i686
> i386 GNU/Linux
> 
> Perhaps this should be reported to the Cygwin maintainers.

FWIW, POSIX allows either behavior ("The low-order digit
shall be rounded in an implementation-defined manner"[1]), therefore,
I agree that the root cause is in your libc, and that you cannot
call it a bug; if you want cygwin's behavior changed, then file the
bug with newlib (since cygwin borrows newlib's printf implementation).

[1] http://www.opengroup.org/onlinepubs/009695399/functions/fprintf.html

On the other hand, I would also file a glibc bug, since QoI argues
that glibc should do the rounding according to the current
rounding mode (and output 1), rather than truncating 0.5 to 0
when rounding it to 0 decimal places.

-- 
Eric Blake

-- 
View this message in context: 
http://www.nabble.com/gawk-round-up-0.5-bug--tp17960779p19732129.html
Sent from the Gnu - Utils - Bugs mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]