# error C2666 VC++ 05, help!

This topic is 4060 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Heres my error: ///// error C2666: 'fmod' : 3 overloads have similar conversions c:\program files\microsoft visual studio 8\vc\include\math.h(561): could be 'long double fmod(long double,long double)' c:\program files\microsoft visual studio 8\vc\include\math.h(513): or 'float fmod(float,float)' c:\program files\microsoft visual studio 8\vc\include\math.h(120): or 'double fmod(double,double)'while trying to match the argument list '(float, double)' ///// How can I fix this?

##### Share on other sites
Since you didn't post any code, I can't be sure, but here's what I think is happening:

You are calling the fmod function like so:
fmod(1.0, 0.0);

In which case, the compiler can interpret those numbers as floats, doubles, or long doubles, so it doesn't know what to do. You can make it explicit by either putting in casts, or, for the float version, appending the letter 'f' to each of the numbers:
//call fmod(double, double)
fmod(static_cast<double>(1.0), static_cast<double>(0.0));

//call fmod(float, float)
fmod(1.f, 0.f);

##### Share on other sites
Coerce the arguments to the appropriate function call in to the same type.

e.g.
fmod(static_cast<double>(x), static_cast<double>(y));

Put yourself in the compiler's shoes. If you were asked to compile fmod(x, y) where x is a float and y is a double, which overload would you choose?

##### Share on other sites
Quote:
 Original post by Driv3MeFarYou are calling the fmod function like so:fmod(1.0, 0.0);In which case, the compiler can interpret those numbers as floats, doubles, or long doubles, so it doesn't know what to do.

Those are both doubles, so that should compile just fine. What is more likely is that one of the parameters is a variable of type float and the other paramter is a constant without F appended to it. For example,
fmod(x,0.5);

where x is a variable of type float. For some reason people tend to use floats when using variables, but doubles when using immediates.

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
16
5. 5

• 14
• 29
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631774
• Total Posts
3002274
×