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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Proper monetary rounding
by monarch (Priest) on Mar 05, 2007 at 16:00 UTC | |
by jonadab (Parson) on Mar 06, 2007 at 16:29 UTC | |
|
Re^2: Proper monetary rounding
by eric256 (Parson) on Mar 05, 2007 at 18:35 UTC |