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: Andreas Schwab
Subject: Re: gawk round-up 0.5 bug?
Date: Wed, 18 Jun 2008 10:26:19 +0200
User-agent: Gnus/5.110009 (No Gnus v0.9) Emacs/22.2 (gnu/linux)

"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.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

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