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

Re: number comparison with a twist

by BillKSmith (Monsignor)
on Mar 02, 2020 at 15:35 UTC ( [id://11113639]=note: print w/replies, xml ) Need Help??


in reply to number comparison with a twist

It is almost never a good idea to test floating point numbers for equality. We can assume that they are 'equal' if their difference is 'sufficiently' small. The definition of 'sufficient' depends on the application. In your case, .01 cent is probably sufficient. This is far larger than any error introduced by floating point. For your current question, this method would use far more of your existing code than any of the exact methods proposed by other monks.
Bill

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-29 12:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found