even after manually casting it its not working same error im gettin
ex :
int x;
x=pow(2,5);
it will give an error C2668: 'pow' : ambiguous call to overloaded function
i want to assign result of pow(x,y) to some integer
but conversion problem how do i convert
if i put like this x=(int)pow(2.0,5); im gettin wrong output i shud get 32
how to do it ?? please help
The error is because parameters (int,int) do not match any directly and implicit casts are equally "good".
You don't need to cast the result, because that is implicit anyway. If the result is wrong, then a rounding floating points during conversion is the reason. You could try int z = pow( static_cast<double>(x), y ) + 0.1;
Then again, integer powers of integer 2 are bitshift operations. No need for pow.