Skip to content
Prev 117751 / 398498 Next

Rounding?

On Mon, 11 Jun 2007, jim holtman wrote:

            
I'll take it you mean a IEC60559 double, which has 53 bits in its implied 
mantissa (it stores 52 and for normalized numbers the leading bit is 1 
and not stored).
All you can say quickly is that its representation is greater than 
6.65:
[1] 8.881784e-16

But I don't think that is the explanation.  Remember that you are using 
binary arithmetic, so each of these numbers is stored with representation 
error.  As the exact number stored is not '6.65', round-to-even does not 
strictly apply.

I get
[1] "6.7"
[1] 6.7
[1] 66
[1] 68

on (several of) my non-Windows systems, so I think this is a Windows 
quirk.  Remember the parsing and printing software has also to run in 
binary on a limited-precision machine, and it does tend to be less 
accurate on Windows than on other ix86 OSes.  (Windows software also tends 
not to implement round-to-even rules.)