[R] seq

Wolski wolski at molgen.mpg.de
Fri Sep 3 14:02:24 CEST 2004


Hi!

For IEEE floating point systems
e_mach= 2^-53  ~=  10^-16 in double precision. 

> identical(seq(0.7, 0, by = -0.1),seq(0.7, 0, length = 8))
[1] FALSE
> a<-seq(0.7, 0, by = -0.1)
> b<-seq(0.7, 0, length = 8)
> a==b
[1]  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE
> (a-b)<10^-16
[1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
> 

Its in the range of machine accuracy (precision).

/Eryk.






*********** REPLY SEPARATOR  ***********

On 9/3/2004 at 1:23 PM Henric Nilsson wrote:

>>>Hi everyone,
>>>
>>>I've tried the below on R 1.9.1 and the 2004-08-30 builds of R 1.9.1 
>>>Patched and R 2.0.0 on Windows 2000, and the results are consistent.
>>>
>>> > seq(0.5, 0, by = -0.1)
>>>[1] 0.5 0.4 0.3 0.2 0.1 0.0
>>>
>>> > seq(0.7, 0, by = -0.1)
>>>[1]  7.000000e-01  6.000000e-01  5.000000e-01  4.000000e-01 
>>>3.000000e-01 
>>>2.000000e-01  1.000000e-01 -1.110223e-16
>>>
>>>Is this really the intended behaviour? I ended up using
>>>
>>> > seq(0.7, 0, length = 8)
>>>[1] 0.7 0.6 0.5 0.4 0.3 0.2 0.1 0.0
>>>
>>>which does what I want.
>>>
>>>//Henric
>>>
>>>______________________________________________
>>>R-help at stat.math.ethz.ch mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



Dipl. bio-chem. Witold Eryk Wolski             @         MPI-Moleculare Genetic   
Ihnestrasse 63-73 14195 Berlin                'v'    
tel: 0049-30-83875219                        /   \       
mail: witek96 at users.sourceforge.net        ---W-W----    http://www.molgen.mpg.de/~wolski 
      wolski at molgen.mpg.de




More information about the R-help mailing list