![]() |
|
laziness, impatience, and hubris | |
PerlMonks |
Re^5: Behaviour of int() unexpectedby LanX (Saint) |
on Mar 13, 2025 at 20:25 UTC ( [id://11164295]=note: print w/replies, xml ) | Need Help?? |
> It's also quite useful when dealing with financial data Financial data, like banks, tax authorities, etc have fixed rules about precision and rounding to avoid ambiguity. And these date back to integer times. You can just calculate in integer if you use cents or the required fractions of them and respect the rounding rules. IOW instead of calculating with a float 5,02€ you calculate with 502¢ or 5020 deci-cents. You only need to "shift" the point once you're putting out the result (best string wise) I haven't seen a case yet where this didn't work.
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|