0

The problem is the following:

sqrt (3) ^ 2 == 3

When the R compiler evaluates this line of code it gives the following result:

> sqrt (3) ^ 2 == 3
[1] FALSE

But this expression can not be FALSE because of the following: (sqrt(x))^2 = x. What is the problem?

  • 2
    Possible duplicate of [Why are these numbers not equal?](http://stackoverflow.com/questions/9508518/why-are-these-numbers-not-equal) also you can have a look here: [Numeric comparison difficulty in R](https://stackoverflow.com/questions/2769510/numeric-comparison-difficulty-in-r) – Rentrop Sep 11 '16 at 19:42
  • ``all.equal(sqrt (3) ^ 2, 3)`` – Cyrus Mohammadian Sep 11 '16 at 19:46
  • And `format(sqrt (3) ^ 2, digits=22)` – Rich Scriven Sep 11 '16 at 19:47

0 Answers0