From spencer at stats.ox.ac.uk  Fri Feb 11 20:13:49 2005
From: spencer at stats.ox.ac.uk (spencer@stats.ox.ac.uk)
Date: Fri Feb 11 20:13:57 2005
Subject: [Rd] double/integer (PR#7687)
Message-ID: <20050211191349.E8D1CDEE7@slim.kubism.ku.dk>

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


[Rd] double/integer (PR#7687)
spencer@stats.ox.ac.uk