Subject: | new() not parsing float strings correctly. |
Expected result:
perl -Iblib/lib -Iblib/arch -E 'use Math::BigInt lib=>"Calc"; say Math::BigInt->new("716115441142293915.0000000000000000000000")'
716115441142293915
With 1.999712:
perl -Iblib/lib -Iblib/arch -E 'use Math::BigInt lib=>"Calc"; say Math::BigInt->new("716115441142293915.0000000000000000000000")'
71611544114229000003915000000000000000000
$ perl -Iblib/lib -Iblib/arch -E 'use Math::BigInt lib=>"Pari"; say Math::BigInt->new("716115441142293915.0000000000000000000000")'
716115441142293915.000000000000000000000000000000000000000
$ perl -Iblib/lib -Iblib/arch -E 'use Math::BigInt lib=>"GMP"; say Math::BigInt->new("716115441142293915.0000000000000000000000")'
0
Note that neither of the two backends will pass tests so these results aren't too surprising.
The old new() would call _new with $$miv, while the new new() calls with the complete input ($wanted).
At a first glance, it looks like:
if ($sgn) {
$self->{value} = $CALC->_new($abs);
} else {
$self->{value} = $CALC->_new($wanted);
}
should be:
$self->{value} = $CALC->_new($abs);
That is, we don't want to pass in the .0* or the e0 or the sign -- just the number.
This solves half the failing tests for Math::BigInt::GMP. The other half are because "infinity" is now allowed and they have tests that it is *not* allowed. Changing the two entries in bigintpm.inc and three in bigfltpm.inc combined with the change above makes Math::BigInt::GMP 1.47 pass tests.