> On Jun 3, 2016, at 6:03 AM, Juan Andres Hernandez <jhernandezcabrera at
gmail.com> wrote:
>
> Can anybody explain me this weird result?
> a=3
> as.integer(a)
> 1] 3
>
> a=(3/10)/0.1
> a
> [1] 3
>
> as.integer(a)
> [1] 2
>
> Thank's in advance
>
> Juan A Hern?ndez
See:
https://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f
Also, note that as per the Value section of ?as.integer:
"Non-integral numeric values are truncated towards zero..."
> print((3/10) / 0.1, 20)
[1] 2.9999999999999995559
> (3/10) / 0.1 == 3
[1] FALSE
Regards,
Marc Schwartz