Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: rboccuzziThat is correct, equality comparisons with regards to floating point numbers can be dangerous. This is true in BRAIN, as in most languages. Both >= and <= also have the same issue.
There is an epsilon parameter in the sort node, and a third parameter that can be passed into the cmp function, which will specify the epsilon to use to determine if two floating point numbers are equal, but you should be cautious with their use or avoid it all together. Unexpected behavior can occur, and you are better off just using < and >.
Think about this: if you have three numbers, 1.2, 1.3, and 1.4, and an epsilon value of .1, then 1.2 == 1.3, and 1.3 == 1.4, but 1.2 != 1.4. This lack of transitivity on the equality of floating points with epsilon can cause issues in the sort node when not doing stable sort, and unexpected behavior in general.
We have provided the tools, but only for use if all else fails, and don't recommend using them. In most cases, you can use < or > to do what you need to, or convert a floating point number to a ranged integer (fixed point) and compare those.
$Rich