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


in reply to Re^2: Proper monetary rounding
in thread Proper monetary rounding

I think he's saying that sprintf actually does that, in just that way:

perl -e 'my $x = 1.5050; my $y = 1.5150; my $s = sprintf "%0.2f\n%0.2f +\n", $x, $y; print $s;' 1.50 1.52

"Normal" (gradeschool) rounding would produce 1.51 and 1.52 there, but sprintf says 1.50 and 1.52, which seems an aweful lot like round-to-even to me. How does it differ from what you wanted?

As far as accountants being picky about this... have you ever seen the movie Superman 3?

-- 
We're working on a six-year set of freely redistributable Vacation Bible School materials.