bug when subtracting decimals?
r-help-bounces at r-project.org napsal dne 21.04.2009 10:00:06:
Petr PIKAL <petr.pikal <at> precheza.cz> writes:
Maybe that is because of Excel is so widespread now and gives expected
results (it probably silently rounds all decimal numbers before calculation).
Marc Schwartz already reminded me of that one, and it's a good point to explicitly mention in lectures. I suggest to extend R by introducing %==% as "being Excellently equal".
It helps but not in all cases
(0.7-0.3)-.4>0
[1] FALSE
(0.7-0.3)-.4<0
[1] TRUE
There always could be different issues with not exact representation of decimals. So educated user or internal rounding could help but I am not sure if later is desired. Regards Petr
Dieter
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.