Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: math problems

by BrowserUk (Patriarch)
on Mar 29, 2011 at 15:07 UTC ( [id://896192]=note: print w/replies, xml ) Need Help??


in reply to Re^2: math problems
in thread math problems

I suspect this will only mask this issue for the OP.

Hm. I don't consider doubling the usable range "masking the problem". More 'taking full advantage of the built-in capabilities whilst dodging the cumbersome and slow bullet of arbitrary precision' until (and if) it is actually required.

I consider moving to Math::BigInt a very last resort. There are Math::Int64 and Math::Int128 to consider before then.

But if his numbers will fit into the unsigned capabilities of the Perl he is using, it doesn't make any sense to seek alternatives for the sake of switching from %d to %u.

I mean, if that is "just masking the problem", then why bother with IVs at all? Why not just have Perl do all math in arbitrary precision and no one would ever encounter these limitations?

Oh right. I remember why now. Because arbitrary precision is dog slow and most of the time we don;t need it.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: math problems
by kennethk (Abbot) on Mar 29, 2011 at 15:14 UTC
    I agree that doubling the range may be a good solution depending on the input. My experience has shown me that increasing a valid range by a factor of two is generally stop-gap, but without more knowledge of the problem this is pure conjecture.

    I would certainly not promote arbitrary precision in the general case, but in this case the OP has (probably) encountered the native limit, and appears to expect an unreasonable 20-digits of precision based on his format string.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2024-04-19 01:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found