Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^3: Equality checking for strings AND numbers

by DrHyde (Prior)
on Jul 17, 2007 at 09:31 UTC ( [id://626987]=note: print w/replies, xml ) Need Help??


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?"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://626987]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-24 07:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found