On Apr 17, 2009, at 9:29 AM, iuhz7j...@sneakemail.com wrote:

A few further oddities (no longer having to do with modular arithmetic):

(0.3 * 3) == 0.9
[1] FALSE
(0.2 * 6) == 1.2
[1] FALSE

This is bad behavior, right?

No...

> (0.3 * 3) - 0.9
[1] -1.110223e-16

> (0.2 * 6) - 1.2
[1] 2.220446e-16


However:

> all.equal(0.3 * 3, 0.9)
[1] TRUE

> all.equal(0.2 * 6, 1.2)
[1] TRUE


See ?all.equal


I feel like I'm going crazy.

Only because you don't understand the etiology of the behavior.

Read:

R FAQ 7.31 Why doesn't R think these numbers are equal?

http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

and call us in the morning....  :-)

HTH,

Marc Schwartz

______________________________________________
R-help@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.

Reply via email to