Subject: | Needs workaround for Math::BigInt::GMP RT 71548 |
Math::BigInt::GMP has a stupid long-standing bug that none of the maintainers will fix. It is a constant PITA that breaks number theory applications.
perl -E 'use Math::OEIS::Grep; Math::OEIS::Grep->search (array => [ 13802006746828966928 ]);'
should find A001252 using the double rule. But it doesn't, because RT 71548 turns 13802006746828966928 into -464473732688058468 when doing the new. This does not happen with the Calc, FastCalc, or Pari backends. It is caused by Math::BigInt::GMP using "mpz_init_set_si" instad of "mpz_init_set_ui" in GMP.xs:_new().
The workaround is to change:
return $bigint_class->new($n);
to
return $bigint_class->new("$n");
in _to_bigint(). This forces Math::BigInt::GMP's string initialization path which works properly.