http://www.perlmonks.org?node_id=115374


in reply to Rounding errors problem

Floating point arithmetic is inherently imprecise. Since you record as pennies, Math::BigInt might be a better choice than Math::BigFloat. Currency exchange rates are, in themselves, a bit fuzzy, so I suggest getting your spec clarified as to how rounding is done, what quotation is used, when the quote is changed, etc. There is an accountant somewhere in this job. There's where to get the real needs.

Update: If Math::BigInt is overkill, what do you need with Math::BigFloat? To round an ordinary perl number, a float, to an integer ($n+.5)|0 or else sprintf "%.0f",$n. Again, talk to the accountant.

After Compline,
Zaxo