Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: number comparison with a twist

by Anonymous Monk
on Mar 02, 2020 at 23:56 UTC ( #11113674=note: print w/replies, xml ) Need Help??


in reply to number comparison with a twist

Since the "authoritative" source of information is in cents ... which is wise ... I think that I would first convert the string to a floating point number, then multiply by 100, then simply truncate to an integer. If the difference is 1 cent, accept the answer.   Part of the problem here is that you have no way to know or of course to control exactly what the other side is doing, what libraries they might be using to talk to you, and so on. I predict that most of the time you actually will get an exact match. When you do not, rounding-error can throw the result off by no more than one cent. "The bane of accountants everywhere."

Replies are listed 'Best First'.
Re^2: number comparison with a twist
by LanX (Archbishop) on Mar 03, 2020 at 00:45 UTC
    > If the difference is 1 cent, accept the answer.

    By far the worst answer yet.

    Very sundial'ish: ignorant, entitled and plain dangerous...

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2020-05-30 18:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (173 votes). Check out past polls.

    Notices?