[Rd] seq() function accuracy inacceptable (PR#8779)

Johannes.Prix at wu-wien.ac.at Johannes.Prix at wu-wien.ac.at
Tue Apr 18 18:19:10 CEST 2006


Full_Name: Johannes Prix
Version: 2.1.1
OS: WinXP, SuSE Linux
Submission from: (NULL) (137.208.41.195)



The seq-command produces unnescessary inaccurate results, which can be extremely
annoying.  I absolutely do not see the nescessity of numerical garbage to appear
in the following simple case.  E.g. try this:

> seq ( 61.55 , 62.00 , by=0.01 ) - round ( seq ( 61.55 , 62.00 , by=0.01 ) ,
digits=2 )

Output looks like:

 [1]  0.000000e+00 -7.105427e-15  0.000000e+00  0.000000e+00 -7.105427e-15
-7.105427e-15  0.000000e+00  0.000000e+00
 [9] -7.105427e-15  0.000000e+00  0.000000e+00  0.000000e+00 -7.105427e-15 
0.000000e+00  0.000000e+00 -7.105427e-15
[17] -7.105427e-15  0.000000e+00  0.000000e+00 -7.105427e-15  0.000000e+00 
0.000000e+00 -7.105427e-15 -7.105427e-15
[25]  0.000000e+00  0.000000e+00 -7.105427e-15  0.000000e+00  0.000000e+00
-7.105427e-15 -7.105427e-15  0.000000e+00
[33]  0.000000e+00 -7.105427e-15  0.000000e+00  0.000000e+00  0.000000e+00
-7.105427e-15  0.000000e+00  0.000000e+00
[41] -7.105427e-15 -7.105427e-15  0.000000e+00  0.000000e+00 -7.105427e-15 
0.000000e+00
> 

It is particularly dangerous to use such seq()-contructed lists (without
rounding) when e.g. trying to find the first time a given number appears in the
list and the number is given without numerical garbage.



More information about the R-devel mailing list