0

Why does the following statement return a FALSE value when it should be TRUE?

=IF(ABS((115.43)-(171 - 21.38 - 34.2))<=0.01,TRUE,FALSE)

115.43 - 115.42 = 0.01

Interestingly, when the threshold value is edited to 0.02, the output is True. I'm using Excel 2010. Appreciate any help! :)

Daniel
  • 45
  • 7

1 Answers1

1

It's to do with the way floating point numbers are represented in binary. When I evaluate 115.43 - 115.42 in VBA, the answer is 1.00000000000051E-02.

Here's a Java-centric post that deals with essentially the same issue, but the short answer is that you shouldn't expect an expression to evaluate to exactly 0.01 when simple mathematics tells you that it should.

jsheeran
  • 2,912
  • 2
  • 17
  • 32