Reputation: 197
I have a very big power
e.x. 5^4912
double x, y, z;
I used z = pow( x, y )
function, but it gives me this result: [ 1.#INF ]
then, I tried to use a for loop that loops in 4912, but it gives me number like
-957893823
which seems rubbish
How can I solve a problem like that?
Upvotes: 0
Views: 3695
Reputation: 11
In order to get large factorials and calculate large values use BigIntegers.
BigInteger in c++
Upvotes: 1
Reputation: 11369
The built-in data types (int, long and even double) can't hold the result of that calculation; so you can't use these.
Depending on the exact use case, I would recommend using a fitting library, e.g.:
Upvotes: 2