Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Math With Big Numbers

by tybalt89 (Monsignor)
on Feb 14, 2019 at 20:44 UTC ( [id://1229919]=note: print w/replies, xml ) Need Help??


in reply to Math With Big Numbers

$bigNumber = Math::BigInt->new(6) ** Math::BigInt->new(25);

Replies are listed 'Best First'.
Re^2: Math With Big Numbers
by syphilis (Archbishop) on Feb 14, 2019 at 22:41 UTC
    $bigNumber = Math::BigInt->new(6) ** Math::BigInt->new(25);

    Or simply:
    $bigNumber = Math::BigInt->new(6) ** 25;
    Perl will print 6 ** 25 as 2.84302880299297e+019 and doing Math::BigInt->new(6 ** 25) therefore becomes Math::BigInt->new(2.84302880299297e+019), which Math::BigInt interprets literally as Math::BigInt->new(28430288029929700000). And that's how AlligatorStamp gets the value he observed.

    With perl, we can also see the actual value by doing:
    C:\>perl -le "printf '%0.f', 6 ** 25;" 28430288029929701376
    And the same should work with AlligatorStamp's perl-5.14.2 ... unless he's running ActivePerl, in which case it will be 28430288029929701000.

    Cheers,
    Rob

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found