This is the nature of floating point - there is no way to represent 2.3 exactly as a floating point binary.
The "2.3" in your first test can't be represented exactly in binary, so it's stored as the closest possible double
, which is 2.2999999999999998
.
In other words, both if
s perform the same comparison.