note
McA
<p>Hi mje,</p>
<p>IMHO your assumption of rounding in <code>Math::FixedPrecision</code> is not true. When you have a look at the constructor of <code>Math::FixedPrecision</code> you'll see the the value 3.145 having 3 digits after the point will be rounded to two digits (what is given as second parameter) with ffround (line 80 of sources).</p>
<p>The effect you see is caused by mathematical (odd) rounding (default of Math::BigFloat) with your example. Have a look at these two examples:</p>
<code>
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;
use Math::FixedPrecision;
my $b = Math::FixedPrecision->new(3.145, 2);
say $b;
# output: 3.14
my $c = Math::FixedPrecision->new(3.155, 2);
say $c;
# output 3.16
</code>
<p>UPDATE: Added output for the reader.</p>
<p>Regards<br/>
McA</p>
1103151
1103172