error C2668: 'pow' : ambiguous call to overloaded function

hello
im gettin this time of error when i convert my project from vs2003 to vs2010
i have changed <math.h> to <cmath> its not working please help me
Just manually cast the arguments to appropiate type.
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
Last edited on
VS 2010 has overloaded pow(s):
http://msdn.microsoft.com/en-us/library/dt5dakze%28v=vs.100%29.aspx

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.
Last edited on
Topic archived. No new replies allowed.