pub fn compare_s(a: f32, b: f32, cond: u8) -> Outcome<bool>Expand description
C.cond.fmt — compare two single-precision values.
§The condition encoding
The 4-bit cond field is systematic, not sixteen unrelated mnemonics
(UM Table 7-11):
| Bit | Meaning |
|---|---|
| 3 | raise Invalid when the operands are unordered (the signaling forms) |
| 2 | true when fs < ft |
| 1 | true when fs == ft |
| 0 | true when the operands are unordered |
So C.EQ is cond = 2, C.OLT is 4, C.OLE is 6, C.UN is 1, and
each signaling variant is its ordinary form plus 8. Writing the sixteen
mnemonics as sixteen cases invites getting one wrong; deriving them from the
bits makes all sixteen correct or none.
Note Greater appears in no bit: fs > ft is simply “none of less,
equal or unordered”, which is why three condition bits suffice. Software
tests it by branching on the complement of C.OLE.