Bug in printf ?

Dave Korn dave.korn@artimi.com
Thu Jun 30 12:34:00 GMT 2005

----Original Message----
>From: Peter Mueller
>Sent: 30 June 2005 13:18

> Hi!
> Peter J. Acklam wrote:
>> haro@NOTYOUTOO! wrote:

   ^^^^^^^^^^^^^  Please avoid quoting peoples email addresses in your
replies, it causes them to suffer more spamming.

>>>>> How come "0.125" gets printed as "0.12", and not "1.3"?
>>>                                                    ^^^ "0.13", off
>>> cource ;-) 
>> 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
> Never heard of such a rule!
> As I learned it in school, 0.5 should allways be rounded to 1 .

  I guess they didn't teach you IEEE-754-compliant floating point maths in
school.  You may find it informative to google some/any/all/none of the
following terms:

dk@mace /artimi/firmware> grep FE_ /usr/include/mingw/fenv.h  | grep 0x0.00
#define FE_TONEAREST    0x0000
#define FE_DOWNWARD     0x0400
#define FE_UPWARD       0x0800
#define FE_TOWARDZERO   0x0c00
dk@mace /artimi/firmware>

Can't think of a witty .sigline today....

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/

More information about the Cygwin mailing list