Can you estimate the value of a power? baseexponent
Last edited on
Why would you want to do that?
Last edited on
what you mean by INT_MAX?
pow
function can take 2 double arguments?
pow() returns +/-HUGE_VAL if the result doesn't fit in a double. Otherwise, you can compare to INT_MAX.
For example:
1 2 3 4 5 6 7 8 9
|
#include <iostream>
#include <cmath>
#include <climits>
int main (){
std::cout <<(pow(2,31)>INT_MAX)<<std::endl;
std::cout <<(pow(2,31)-1>INT_MAX)<<std::endl;
return 0;
}
|
Last edited on
b^e exceeds 2^32 (unsigned 32 bit integer) iff
e * ln(b) / ln(2) > 32
hey thanks! thats really cool i figured it be somethin with e
Just in case...
'e' in the case above is not the mathematical 'e'... it is just a (poorly chosen) variable.