A coworker discovered what seemed to be a problem with the C# modulus operator for the float datatype. I wrote this little bit of C code and compiled it with MinGW and got the same results. I skimmed through several fmod related threads but found mostly programming problems. Since I got pretty much the same results in C# with VS2008 and C with gcc I figured someone else might have some insight.

Here is the code:

Code:
#include <stdio.h>
#include <math.h>

int main(int argc, char **argv)
{
  double M1 = fmod(323.2,0.001);
  double M2 = fmod(323200.0,1.0);

  printf ("fmod(323.2,0.001)=");
  printf ("%f", M1);
  printf ("\n\n");
  printf ("fmod(323200.0,1.0)=");
  printf ("%f", M2);
  printf ("\n");
}
And here are the results:

fmod(323.2,0.001)=0.001000

fmod(323200.0,1.0)=0.000000

Note that the first one is the problem. It should output zero. Multiplying by 1000.0 gives the expected result. The problem was originally seen in C# and the result was slightly less than 0.001 (0.000999...).

Does that seem right to you?