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

From: <Johannes.Prix_at_wu-wien.ac.at>
Date: Tue 18 Apr 2006 - 16:19:10 GMT


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.



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Apr 19 02:20:47 2006

This archive was generated by hypermail 2.1.8 : Wed 19 Apr 2006 - 04:17:45 GMT