As you have already observed, the number 1000000.123 is stored as 1000000.125. This is rendered as-is by double.ToString()
, but truncated by float.ToString()
because showing too many digits is misleading.
Incidentally, there is no Convert.ToSingle(float)
because it would simply return exactly what you passed in. Your code is actually resolving to Convert.ToSingle(double)
. You are thus (implicitly) converting to double
and then (explicitly) back to float
, which is a no-op, essentially.
Caution: Don't trust JavaScript floating point calculators. Some of them assert that 1000000.123 is stored as 1000000.1 by single-precision floats, which I'm guessing is based on the assumption that, because IEEE floats have roughly 7.22 digits of precision, they can be accurately represented in 8 digits. This is incorrect.