[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
printf("%.0f", 0.5) and round-to-even
From: |
Eric Blake |
Subject: |
printf("%.0f", 0.5) and round-to-even |
Date: |
Mon, 29 Sep 2008 21:41:36 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
An interesting question popped up on the bug-gnu-utils list:
http://lists.gnu.org/archive/html/bug-gnu-utils/2008-09/msg00055.html
POSIX states that with %f, the low-order digit is rounded in an implementation-
defined manner. However, since 0.5 is exactly half-way between 0 and 1, and
most machines default to IEEE round-to-even, should we make the gnulib printf-
posix check enforce that printf("%.0f", 0.5) outputs "0" per round-to-even
rules? If so, then at least cygwin 1.5.x fails this check, by outputting "1".
--
Eric Blake
- printf("%.0f", 0.5) and round-to-even,
Eric Blake <=