diff --git a/crates/xenia-cpu/src/fpscr.rs b/crates/xenia-cpu/src/fpscr.rs index 535a500..24ac3ff 100644 --- a/crates/xenia-cpu/src/fpscr.rs +++ b/crates/xenia-cpu/src/fpscr.rs @@ -286,7 +286,12 @@ fn round_single_toward_zero(v: f64) -> f32 { if rn.is_nan() || rn.is_infinite() || rn == 0.0 { return rn; } if rn.abs() as f64 <= v.abs() { return rn; } let adj_bits = rn.to_bits(); - let lower = if rn.is_sign_positive() { adj_bits - 1 } else { adj_bits - 1 }; + // Both positive and negative finite f32 values have the IEEE-754 sign + // bit as the MSB; subtracting 1 from `to_bits()` always reduces the + // magnitude by one ULP (clearing the lowest mantissa bit, with carry + // never reaching the sign bit since adj_bits is already not-zero, + // not-inf, not-NaN, and we already returned early for those). + let lower = adj_bits - 1; f32::from_bits(lower) }