http://qs321.pair.com?node_id=1142133


in reply to Odd error message

MPU is very strict about getting integers, as it is very easy for Perl to suddenly decide a large number is a float. This is almost always something Very Bad when doing number theory. I chose to have it complain instead of giving subtly wrong results.

One of the problems here is the merit calculation needs to be done using FP logs. This is why, if you look at my gap software, everything is a bigint except the merit calculation, done in a sub that explicitly converts to BigFloats. It's a PITA, and Perl6 / PARI are much nicer in this.

Anyway, $fact*$i could easily overflow (primorial(31)*3e8 is larger than 64-bit). You need to do something like my $fact = Math::BigInt->new(primorial(31)); to force $num to be a bigint. Then the merit calc should be done as a sub that uses Math::BigFloat.