Derek Jones schreef:

> All of the common languages suffer from rounding problems inherent in
> IEEE rounding (round-to-even and other issues). Math::Round resolves
> these issues.

If you don't round to even (and your numbers are of the same sign), then
the totals of the original values and the total of the rounded values
will be more different.
That is why round-to-even is also called "bankers rounding", for details
see http://en.wikipedia.org/wiki/Rounding


> $a=4712.5;
>
> $b=round $a;
>
> printf "%s %5.0f %5.0f\n", $a, $a, $b;
>
>
> I hit this while comparing SAS output (which does do proper (within
> machine limits) "mathematical" rounding that we all learned about in
> school. The C libraries from which Perl and other C-lib derived
> languages take their rounding functions are the cause of some
> potential grief here and comparison with 4 other languages vs. SAS
> showed SAS getting it right each time. Using Math::Round - so did
> Perl. We're talking way down to DP as well.
>
> This caused the group I work with some issues as I was rewriting some
> SAS code in Perl and our regression tests were not matching - and we
> were talking adding up millions of rows of data with N DP to be
> concerned about. Math::Round fixed that.

Are you sure that your regression tests were "right"?
:)

-- 
Affijn, Ruud

"Gewoon is een tijger."

Reply via email to