Skip to main content

is_snan_f32

Function is_snan_f32 

Source
pub const fn is_snan_f32(v: f32) -> bool
Expand description

Is this f32 a signaling NaN as the VR4300 classifies one?

§The convention is inverted from IEEE-754:2008

IEEE-754:2008 says the significand’s MSB set means quiet. The VR4300 predates that edition and uses the legacy MIPS convention, where the significand MSB set means signaling. So 0x7FC0_0000 — the pattern every modern language calls a quiet NaN, and what Rust’s f32::NAN is — is a signaling NaN to this processor, and raises Invalid.

§How this was established

Not from a manual: from n64-systemtest’s own expectations, which name their constants by the IEEE convention and then assert the opposite behavior. For a non-signaling compare (C.EQ, C.F, …) it expects QUIET_NAN_START_32 (0x7FC0_0000, MSB set) to raise Invalid and SIGNALING_NAN_END_32 (0x7FBF_FFFF, MSB clear) to raise nothing. The signaling compare forms (C.SF, C.SEQ, …) raise Invalid for both, which is the ordinary IEEE rule for those forms and so does not distinguish them.

The corroboration that makes this more than a curve fit: the VR4300’s own default NaN result is 0x7FBF_FFFF, MSB clear. Under IEEE that would be a processor whose invalid-operation result is a signaling NaN — absurd, since it would re-trap on first use. Under this convention it is exactly what it should be, a quiet one.

Accuracy ledger C-12.