SV: Bug in printf ?

Dave Korn
Thu Jun 30 13:10:00 GMT 2005

----Original Message----
>From: Peter J. Acklam
>Sent: 30 June 2005 13:13

> Dave Korn [dave.korn@NONONOATHOUSANDTIMESNO] wrote:
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ please!  TIA!

>> haro@OOPSNOTAGAIN wrote:
>>> How come "0.125" gets printed as "0.12", and not "1.3"?
>> Absolutely, there's a rounding error of some sort.
> For what it's worth: My Sunblade 100 running Solaris 9 has
> Solaris' /bin/printf and GNU's printf as /usr/local/bin/printf
> and both give "0.12", not "0.13".
> I am quite sure it is the printf returning "0.13" that is buggy.

  Have you considered that your sunblade might be operating in a different
rounding mode, by default?

> Note that the value "0.125" can be represented exactly with IEEE
> double precision arithmetic, so inexact representation is not the
> matter here.

  I never suggested it was.  Nonetheless, I would imagine that printf may
well work under-the-hood by shifting the desired decimal places above the
point, rounding to integer, and printing out that number.

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

Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list