[Rd] double/integer (PR#7687)

From: <spencer_at_stats.ox.ac.uk>
Date: Sat 12 Feb 2005 - 06:13:49 EST


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

test
FALSE TRUE
 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



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Feb 12 05:20:41 2005

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:02:51 EST