MSDN:
Single values have less precision than Double values. A Single value that is converted to a seemingly equivalent Double often does not equal the Double value because of differences in precision. In the following example, the result of identical division operations is assigned to a Double and a Single value. After the Single value is cast to a Double, a comparison of the two values shows that they are unequal.
http://msdn.microsoft.com/en-us/library/system.double.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-7[
^]
When you write the line
double f = 10.123 - 10.0;
it is the same as to write
double f = 10.123d - 10.0d;
as C# default is to double precision floating point...
There is no way to get the exact value but you can get closer (or further) to it...All you have to do is to decide what the precision you need...
for example by changing your line to
double f = 10.123f - 10.0f
you will get the result of 0.12300014495849609...
As you can see at the bottom line you will have to play with rounding up/down while using floating point numbers...
However you are fortunate - this problem of floating points was known to Microsoft and there is an other type that can be used for floating point computations -
decimal[
^]...
It has it drawbacks (read the MSDN page) but for your range (according to your case) it will give the correct answer. Try...
decimal f = 10.123m - 10.0m;