in reply to Dealing with rounding errors (Using Math::BigInt)
Well, BigInt only deals with integers, so the "accuracy" and "precision" settings will be ignored if negative (see bigint and Math::BigInt).
Historically, currency calculations were done in BCD, which is one approach.
My suggestion would be to do all the calculations as integers, in mils (tenths of a cent), rounding with explicit code, i.e., don't rely on rounding rules buried in sprintf, bigint, or bigfloat, and converting to dollars and cents when required. If you're doing this for tax calculations, I would expect that the appropriate tax authorities will have tables listing how much tax (in cents) is applicable to purchases of a given amount. They may also have rounding rules they require to be followed.
added in edit
Or heed jdtoronto's suggestion and look at Math::Currency
emc
|
|---|