Skip to content

double/integer (PR#7687)

2 messages · spencer@stats.ox.ac.uk, Thomas Lumley

#
Full_Name: Chris Spencer
Version: 2.0.1
OS: Linux
Submission from: (NULL) (163.1.211.93)


Dear R team,

I realise that the following is a bit unsafe (the combination of doubles and
integers), however I wondered whether the following behaviour is expected:
test
FALSE  TRUE
 1472 98528

For example I can also make the following error:
[1] 259765
[1] 259762

Would you expect this to be the case and if so why?
Thanks for your help.

Chris Spencer
#
On Fri, 11 Feb 2005 spencer@stats.ox.ac.uk wrote:

            
Certainly.  You might even expect worse behaviour than that.

temp can be exactly represented in double precision only when i is a 
multiple of 125.  Depending on exactly how the computations are done and 
how many extra guard digits are carried you could get FALSE for nearly all 
i not a multiple of 125.  The fact that you get TRUE 98% of the time is 
better accuracy than you should expect.


 	-thomas