Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Odd error message

by danaj (Friar)
on Sep 15, 2015 at 21:14 UTC ( [id://1142133]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1142133]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-20 00:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found