The last decimals are certainly wrong, but it seems that we can say that 5.194693e+308254 is a fair approximation, obtained in 39 milliseconds.$ time perl -E 'my $c = log(2) * 1024000; my $d = $c / log(1e100); > $d = int $d; say $d; $c = $c - log(1e100) for 1..$d; > say $c; say "Value is: ", exp $c, " x 1e${d}00";' 3082 125.987232628425 Value is: 5.19469341155068e+54 x 1e308200 real 0m0.039s user 0m0.030s sys 0m0.000s
Update (at 16:36 UTC): A better version of more or less the same:
Update 2: fixed a wrong print out of the value.$ time perl -E 'my $c = log(2) * 1024000; my $d = int ( $c / log(1e10 +0)); > say $d; $c = $c - $d * log(1e100); > say $c; say "Value is: ", exp $c, " x 1e${d}00";' 3082 125.987232618965 Value is: 5.19469336241126e+54 x 1e308200 real 0m0.036s user 0m0.000s sys 0m0.046s
In reply to Re: Efficiently working with huge exponents
by Laurent_R
in thread Efficiently working with huge exponents
by wanna_code_perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |