in reply to Re^2: Equality checking for strings AND numbers
in thread Equality checking for strings AND numbers

I'd argue that if you're bothering to mention precision at all, then 10.0 != 10.00.

10.0 is really "somewhere between 9.95 and 10.05", and 10.00 is really "somewhere between 9.995 and 10.005". So if your 10.0 is really 9.97, it can't possibly be equal to 10.00.

  • Comment on Re^3: Equality checking for strings AND numbers

Replies are listed 'Best First'.
Re^4: Equality checking for strings AND numbers
by Anonymous Monk on Jul 17, 2007 at 12:05 UTC
    I guess it all comes down to how precise you want equality test to be in this program. If you want exact on the money the only way to get that I have ever seen is to do a direct string comparison as mentioned above. In this case 10.0 != 10.00. The reply to this suggestion before was that (10.0 == 10.00) evaluated to true. So it comes down to the basic question that has been asked throughout this post

    "How Precise do you want the numeric comparison to be?"