Rob Coops <rco...@gmail.com> asked:
> I am just wondering if I sumbled upon an error in perl an error in my
> logic or somehtign else see the below perl one liners
> 
> $ perl -e '$n = 0.945; $r = sprintf("%.2f", $n); print "$r\n";'
> 0.94

Short answer: You shouldn't use floating point numbers for financial 
calculations. Instead, calculate in cent-based integer values.

Long answer: "perldoc -q round", "perldoc perlnumber".

HTH,
Thomas



Reply via email to