<sub> Nb. I answer this question as it is also tagged with C ++
Due to errors in representing the float in C ++, the above gives false, since the two floating-point numbers are not quite equal.
eg. the internal representation for 0.1 is close to this value, but not exactly that

The same is true for C #.
Let me relate a well-known document that (imho), every programmer engaged in floating point arithmetic should read: What every computer scientist should know about floating point Arithmetic
source share