[R] Funky calculations

Ivan Krylov
Tue, 01 Feb 2022 16:35:57 -0000

On Tue, 1 Feb 2022 20:45:40 +0700
Nathan Boeger <nboeger at gmail.com> wrote:

> I found something strange and maybe I am going nuts but this does not
> make sense:
>
> >  (0.4 + 0.2 + 0 + 0.3 + 0 + 0.1) > 1
> [1] TRUE

Unfortunately, this always happens when computers approximate real
numbers with fractions in binary. See R FAQ 7.31 (RShowDoc('FAQ') or
<https://cran.r-project.org/doc/FAQ/R-FAQ.html>).

--
Best regards,
Ivan