This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

fmod producing strange results

Hello
I am getting strange results for the fmod function in math.h.

float f, g;
for (f = 0.0; f < 4.0 * PI; f += (5.0 * PI / 180.0)) {
g = fmod(f, (2.0 * PI));
printf("%f %f\r\n", f * 180.0 / PI, g * 180.0 / PI);
}

For first sweep from 0.0 to 2 * PI, I get zero for remainder, for second sweep from 2 * PI to 4 * PI if get sensible numbers. Compared in Visual C++ and first sweep produces remainders as expected.

Is this a bug in fmod?

Thanks!

0