Hello Monks!
I need to work with some rather large exponents (much too big for ordinary Perl scalar), on the order of 2**1024000.
Here's my test program:
#!/usr/bin/env perl use 5.014; use Math::BigFloat; my $POW = 1024000; my $n = Math::BigFloat->new(2); say "BigFloat result: " . $n->pow($POW);
On my system, this takes over 3 minutes to run, and works with perfect precision (i.e., I get a 308255-digit integer). I don't need perfect precision, so I set $n->accuracy(10);, which is plenty for my purposes. However, I still get a huge integer as a result (only this time, it's mostly zeroes), and it still takes over 3 minutes to run.
What I want is a limited-precision floating point number such as 5.194693e308255, that I can compare to other such numbers for sorting, display, and the like. Any more than, say, 10 significant figures, is a waste.
Is there a way (with or without BigFloat) to (quickly) calculate a limited-precision float like 5.195e308255? I feel like I'm missing something obvious.
In reply to Efficiently working with huge exponents by wanna_code_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |