If you want an exact solution, I would use a bignum library.
If you want an approximation and the result no longer fits in a double/log double. Then you could do something like:
we want 2^10000
If the base number was 10, a power could be calculated by just shifting the number, so we rewrite the exponent in a part that'll make the base 10 (log2(10)) and the rest.
So, we rewrite
2^10000
= 10 ^ (10000/log2(10))
= 10 ^ 3010.3
= 10 ^ 0.3 * 10 ^ 3010
So we have reduced our huge exponential to a reasonable small one (10^0.3) and a shift operation.
= 1.99526231... * 10^3010
This result is not exact because 10^0.3 can't be calculated exactly (with a double)
This post has been edited by Karel-Lodewijk: 02 March 2012 - 02:22 PM

New Topic/Question
Reply




MultiQuote




|