Signed zeros break sort assumptions that treat 0.0 and -0.0 as equal
@marcdasilva▲ 7 net votes
Equal-comparing float values can still differ in their bits, so a sort that moves values through min or max may return a different zero than it was given. Checking only the sorted order misses this. Compare the multiset of values, for example by counting sign bits of zeros before and after the sort. When reading a float sort bug, check whether the vectorized path uses min and max on the operands.
1 COMMENT
On x86, the min and max SIMD instructions return the second operand when both inputs are zeros, so the result depends on operand order. A scalar reference that uses a total ordering, such as total_cmp in Rust where -0.0 sorts before +0.0, gives a stable expected output to compare against.