Skip Menu |

This queue is for tickets about the Math-OEIS CPAN distribution.

Report information
The Basics
Id: 97221
Status: resolved
Priority: 0/
Queue: Math-OEIS

People
Owner: Nobody in particular
Requestors: DANAJ [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 3
Fixed in: (no value)



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.
CC: DANAJ [...] cpan.org
Subject: Re: [rt.cpan.org #97221] Needs workaround for Math::BigInt::GMP RT 71548
Date: Tue, 15 Jul 2014 19:18:20 +1000
To: bug-Math-OEIS [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"Dana Jacobsen via RT" <bug-Math-OEIS@rt.cpan.org> writes: Show quoted text
> > return $bigint_class->new("$n");
Thanks. I think I've done that elsewhere for that reason. I don't think I need the gmp back end as such so I'll take that "try" away too. (But still stringize in case someone else selected it ...)
On Tue Jul 15 05:18:51 2014, user42_kevin@yahoo.com.au wrote: Show quoted text
> "Dana Jacobsen via RT" <bug-Math-OEIS@rt.cpan.org> writes:
> > > > return $bigint_class->new("$n");
> > Thanks. I think I've done that elsewhere for that reason. I don't > think I need the gmp back end as such so I'll take that "try" away too. > (But still stringize in case someone else selected it ...)
Looks good. I think this can be closed. Stripped.pm is still using try GMP and new without quotes. It turns out this works fine because the values are coming from splitting a string, hence are strings rather than UV/IVs, so things are good. The digit length logic in Stripped.pm will convert more numbers than necessary, but that is probably not an issue unless the user does comparisons on them and they're Math::BigInt::GMP objects. Doing precise comparisons is a pain and much messier, so this is probably good.
CC: DANAJ [...] cpan.org
Subject: Re: [rt.cpan.org #97221] Needs workaround for Math::BigInt::GMP RT 71548
Date: Sat, 02 Aug 2014 14:53:08 +1000
To: bug-Math-OEIS [...] rt.cpan.org
From: Kevin Ryde <user42_kevin [...] yahoo.com.au>
"Dana Jacobsen via RT" <bug-Math-OEIS@rt.cpan.org> writes: Show quoted text
> > Stripped.pm is still using try GMP and new without quotes. It turns > out this works fine because the values are coming from splitting a > string, hence are strings rather than UV/IVs, so things are good.
Good. Show quoted text
> The digit length logic in Stripped.pm will convert more numbers than > necessary,
Hmm. Yes, I didn't feel like trying to tell precisely when it was needed. Maybe I could document the secret use_bigint=>'if_necessary' option to offer control.