I sense that you may not be satisfied with the answer, still feeling that it is "not logical" for one to work and the other not.
Let's see if I can explain in a way that will make you feel better about it.
Since these numbers involve fractional values, the computations are done with floating point numbers, which internally are a long string of bits that represent numbers APPROXIMATELY, to many decimal places.
When the system does the subtraction in the first case, it just happens to work out that all the low order bits were the same, so that is was equal to the internal representation of 0.5.
When it does the subtraction in the second place, it happened that some low order digits in the two representations were not the same, so even though the result was VERY close to 0.4, it was not exactly the same as 0.4. So the comparison fails.
This is how floating point arithmetic works, in any system, or on paper, or with a calculator. Answers are approximate to the number of decimal places used, and you cannot depend on EXACT comparisons.