0

I came across with a stupid question today for R. I am using R version 3.4.4 and RStudio version 1.1.423.

test <- 1682.2- 1681.8
test
0.400000000000091

Isn't the value test supposed to be exactly 0.4?

Ralf Stubner
  • 26,263
  • 3
  • 40
  • 75
Jian
  • 365
  • 1
  • 6
  • 19
  • 0.400000000000091 is equal to 0.4: `all.equal(0.400000000000091, 0.4)` – missuse Jun 04 '18 at 13:35
  • I think mussuse's comment is misleading. Adjust your mental framework when working with computers to not ever use "exactly equal" for non-integer numbers. If there are decimals, there needs to be a precision tolerance. – Gregor Thomas Jun 04 '18 at 13:51

0 Answers0