[R] R rounding problem?
array chip
@rr@ypro|||e @end|ng |rom y@hoo@com
Fri Sep 4 06:46:58 CEST 2020
Hello,
I made a mistake today on simple counting in R, that almost got me into trouble. After trying multiple times, I finally figured out it's rounding issue in R.
For exmaple, when I just simply type:
> (6.9-6.3) > 0.6
[1] TRUE
6.9-6.3 should be 0.6 exactly, but R thinks that it's greater than 0.6!!
Similarly, R thinks 5.6-5.5 is smaller than 0.1:
> (5.6-5.5) < 0.1
[1] TRUE
Why is the above happening? This rounding issue seems to be small, but this could cause serious problem in real world.
Can anyone shed a light on how to avoid the issue?
Thanks,
Yi
More information about the R-help
mailing list