Problem using the "pow" function
-
I have six lines in my code similar to the following: Biquad[0]->mfVh = pow(10, (0.05*mfGh)); On compiling the program I get the following error: error c2666: 'pow': 7 overloads have similar conversions. Could somebody explain to me what this means. Biquad[i] is an object of cBiquad. mfVh and mfGh are floats. I've tried suffixing 10 and 0.05 with f, but that gives me a separate error saying that the use of the suffix there is incorrect. If you could let me know what I'm doing wrong it would be of great help! Thanks!
-
I have six lines in my code similar to the following: Biquad[0]->mfVh = pow(10, (0.05*mfGh)); On compiling the program I get the following error: error c2666: 'pow': 7 overloads have similar conversions. Could somebody explain to me what this means. Biquad[i] is an object of cBiquad. mfVh and mfGh are floats. I've tried suffixing 10 and 0.05 with f, but that gives me a separate error saying that the use of the suffix there is incorrect. If you could let me know what I'm doing wrong it would be of great help! Thanks!
I seem to have fixed it by some kind of brute casting technique. The line now reads: Biquad[0]->mfVh = pow((float)10, (float)(0.05*mfGh)); Here's a link to the MSDN document if somebody else has a similar problem ERROR C2666 Suggestions for more elegant solutions are welcome!
-
I seem to have fixed it by some kind of brute casting technique. The line now reads: Biquad[0]->mfVh = pow((float)10, (float)(0.05*mfGh)); Here's a link to the MSDN document if somebody else has a similar problem ERROR C2666 Suggestions for more elegant solutions are welcome!
-
I had the same problem. Are you using VS2003? It doesnt seem to be a problem in vs6 Change your code like this. Its a bit neater Biquad[0]->mfVh = ::pow(10.0, 0.05*mfGh);
Josh, Thanks for the tip, and yes, I'm using VS2003. That's a really weird error...digging through the MSDN documentation helped a little and I typecasted everything that could be (even the result, but apparently that wasn't required). I like your solution better. Could you please explain what the "::" does? Thanks again!
-
Josh, Thanks for the tip, and yes, I'm using VS2003. That's a really weird error...digging through the MSDN documentation helped a little and I typecasted everything that could be (even the result, but apparently that wasn't required). I like your solution better. Could you please explain what the "::" does? Thanks again!
The :: means "the pow() function from the globalname space". This is redundant if you dont use namespaces, and probably if you do but I like to use it when calling functions from the c library as it makes the code a bit easier to read im my opinion. Look at the declaration of the pow() template function in math.h if you are still unsure about how to use it