I'd go straight to Math::MPFR (which uses the mpfr library, which in turn uses the gmp library).
However, in doing so I'm plugging one of my own modules - which perhaps lessens the value of my advice.
Anyway, on my Windows box:
C:\_32>perl -MMath::MPFR=":mpfr" -le "Rmpfr_set_default_prec(1024001);
+$x = Math::MPFR->new(2); $x **= 1024000; print $x;" >out.txt
The output file reveals:
5.194693363199925.....490149376e308254
The result is instant (maybe a quarter of a second).
The length of the string that is output correlates nicely to yours. It is 308263, which is 308255 + 1 (for the decimal point) + 7 (for the "e308254").
Do we also agree on the value ?
Maximum precision for my mpfr library (and hence for my Math::MPFR) is 1073741823 bits.
Update: Just noticed that the OP now specifies that full precision is not required:
perl -MMath::MPFR=:mpfr -le "Rmpfr_set_default_prec(28);print Math::MP
+FR->new(2) ** 1024000;"
5.194693363e308254
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.