A common problem with floating point comparisons is that they can easily get a rounding error. When you take a value like 1.2 (which cannot be exactly represented as a decimal), multiply it by 100 and compare it for equality with 120 . The recommendation is to always compare the difference like this:
var a = 1.2; a *= 100; if (a - 120 < 0.0001) { }
However, the Math.Floor operation always results in an integer value. That is, any fractional values ββwill be truncated, and the exact integer value will remain.
So, if your semantics really should use gender, you're safe.
However, if you are really trying to round, use Math.Round () instead.
source share