I am doing some math with doubles in C#. There's a piece of my code:
for(int i = 0 ;; i++){
double step = num / Math.Pow(10,i + 1);
step = step - Math.Floor(step);
step = step * 10;
Console.WriteLine(step + " " + Math.Floor(step));
...
}
So, I get that problem when num
equals 14. In the first iteration (i
equals 0) Console.WriteLine
gives an output 4 3
, which means Math.Floor(4)
returned 3. Is it some double type problem or what?