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

Oct 3, 2013 at 12:19pm
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
Oct 3, 2013 at 1:04pm
Just manually cast the arguments to appropiate type.
Oct 4, 2013 at 6:11am
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 Oct 4, 2013 at 6:35am
Oct 4, 2013 at 8:34am
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 Oct 4, 2013 at 8:35am
Topic archived. No new replies allowed.