in reply to Efficiently working with huge exponents
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficiently working with huge exponents (yeah)
by tye (Sage) on Mar 20, 2015 at 17:53 UTC | |
by Laurent_R (Canon) on Mar 20, 2015 at 21:54 UTC | |
by tye (Sage) on Mar 20, 2015 at 22:48 UTC | |
by wanna_code_perl (Friar) on Mar 21, 2015 at 13:55 UTC | |
by syphilis (Archbishop) on Mar 22, 2015 at 01:14 UTC | |
by wanna_code_perl (Friar) on Mar 22, 2015 at 13:04 UTC |