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: mcollado
Subject: Re: gawk round-up 0.5 bug?
Date: Wed, 18 Jun 2008 12:55:27 +0200
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Andreas Schwab escribió:
"Jeff Chua" <address@hidden> writes:

This is intended to be?

# awk 'BEGIN {printf("%.0f\n", 0.5)}'
0

# awk 'BEGIN {printf("%.0f\n", 0.51)}'
1

# gawk --version
GNU Awk 3.1.6

I would think 0.5 should be rounded to 1.

Since 0.5 is exactly half-way between 0 and 1 it is rounded to the
nearest even number.  This is the default rounding mode for IEEE
floating point systems.

So it is not symmetric? - see http://en.wikipedia.org/wiki/Rounding

--
Manuel Collado - http://lml.ls.fi.upm.es/~mcollado


reply via email to

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