> On Jun 3, 2016, at 6:03 AM, Juan Andres Hernandez 
> <jhernandezcabr...@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

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to