Consider this:
double x,y; x =120.0; y = 0.05; double z= x % y;
I tried this and expected the result to be 0, but it came out 0.04933333.<
This is what we use.. :)
public double ModuloOf(double v1, double v2) { var mult = 0; //find number of decimals while (v2 % 1 > 0) { mult++; v2 = v2 * 10; } v1 = v1 * Math.Pow(10, mult); var rem = v1 % v2; return rem / Math.Pow(10, mult); }