Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: finding the correct integer

by LanX (Saint)
on Nov 30, 2020 at 14:57 UTC ( [id://11124398]=note: print w/replies, xml ) Need Help??


in reply to finding the correct integer

That's a classic, computers use a binary representation for floats and many decimal fractions can't be represented w/o rounding errors

see Humans have too many fingers

Depending on use case there are different solutions, one is to calculate with integers without decimal fractions (like do currency in cent and add the point only at output)

PS: we had a similar discussion just recently

int() function

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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-25 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found