Subject: | Accuracy and precision are both set in some cases |
The following code causes both the precision and the accuracy to be set, which is illegal, so $x becomes NaN, not 5. In addition, the returned precision and accuracy are the class variables, not the instance variables set via new().
===BEGIN-CODE===
use Math::BigInt;
# set class variable
Math::BigInt->precision(-4);
# specify accuracy to the constructor
my $x = Math::BigInt->new(5, 3, undef);
say "x = ", $x;
say "a = ", $x->accuracy() // "undef";
say "p = ", $x->precision() // "undef";
===END-CODE===
The output is
x = NaN
a = undef
p = -4
but should have been
x = 5
a = 3
p = undef
This bug is present in all versions of Math::BigInt.