[Rd] double/integer (PR#7687)

spencer at stats.ox.ac.uk spencer at stats.ox.ac.uk
Fri Feb 11 20:13:49 CET 2005

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

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 R
> test <- vector(length=100000);
> for(i in 1:100000){temp = i/1000; test[i] = (i == temp*1000);}
> table(test);
 1472 98528

For example I can also make the following error:

>  as.integer(259.765*1000);
[1] 259765
>  as.integer(259.763*1000);
[1] 259762

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

Chris Spencer

More information about the R-devel mailing list