Re: [R] 0.1 + 0.2 != 0.3 revisited

2004-02-09 Thread Christian Hoffmann
Hi, IEEE says that real numbers are normalized (a few below 10^(-16) may be not [gradual underflow]), so that they look like 0.1ddd2^ex. Then only ddd and ex are kept: 0.1 = 0.00011.. 2^0 = 0.11001100.. 2^(-3) - (11001100.., -3) 0.2 = 0.0011.. 2^0 = 0.11001100.. 2^(-2) - (11001100.., -2) 0.3 =

Re: [R] 0.1 + 0.2 != 0.3 revisited

2004-02-09 Thread Peter Dalgaard
Christian Hoffmann [EMAIL PROTECTED] writes: 0.1 would be stored as (1 + 0.6)*2^(-4) and 0.2 would be stored as (1 + 0.6)*2^(-3), whereas 0.3 would be stored as (1 + 0.2)*2^(-2). You should expect 56 decimal (binary?) place accuracy on 0.1, 55 place accuracy on 0.2, and 54 place accuracy

Re: [R] 0.1 + 0.2 != 0.3 revisited

2004-02-09 Thread Duncan Murdoch
On Mon, 09 Feb 2004 08:52:09 +0100, you wrote: Hi, IEEE says that real numbers are normalized (a few below 10^(-16) may be not [gradual underflow]), so that they look like 0.1ddd2^ex. Then only ddd and ex are kept: 0.1 = 0.00011.. 2^0 = 0.11001100.. 2^(-3) - (11001100.., -3) Right, that's

[R] 0.1 + 0.2 != 0.3 revisited

2004-02-06 Thread Simon Fear
Prompted by Peter Dalgard's recent elegant intbin function, I have been playing with the extension to converting reals to binary representation. The decimal part can be done like this: decbase - function(x, n=52, base=2) { if(n) { x - x*base paste(trunc(x), decbase(x%%1, n-1, base),

Re: [R] 0.1 + 0.2 != 0.3 revisited

2004-02-06 Thread Duncan Murdoch
On Fri, 6 Feb 2004 12:55:05 -, Simon Fear [EMAIL PROTECTED] wrote : Prompted by Peter Dalgard's recent elegant intbin function, I have been playing with the extension to converting reals to binary representation. The decimal part can be done like this: decbase - function(x, n=52, base=2) {