This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bug in printf ?


On Thu, Jun 30, 2005 at 09:44:57PM +0900, haro@kgt.co.jp wrote:
> ::Dealing with integers illustrates the matter more clearly. When
> ::the decimal value is exactly 0.5, then printf should round to the
> ::nearest *even* integer, as far as I know, so you should get
> 
> Hi Peter,
> 
> Thank you for your explanation. I didn't know, until now, that
> rounding should be done to the "nearest *even* integer".
> Need to learn every day. ;-)

This is done to prevent systemic bias.

However, note that
http://www.opengroup.org/onlinepubs/009695399/functions/printf.html says:
"The low-order digit shall be rounded in an implementation-defined manner."
so while people have come to expect unbiased rounding, it isn't actually
mandatory AIUI under vanilla SUSv3.

Also see "What Every Computer Scientist Should Know About
Floating-Point Arithmetic" at (among other places)
http://docs.sun.com/source/806-3568/ncg_goldberg.html.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]