pub fn mul_div_i32(a: i32, b: i32, c: i32) -> i32Expand description
a * b / c through the full 64-bit product, truncated toward zero:
identical to (i64::from(a) * i64::from(b) / i64::from(c)) as i32 for
every input, with no 64-bit helper call.
This is the signed fixed-point workhorse: a Q-format multiply is
mul_div_i32(a, b, ONE), a Q-format divide mul_div_i32(a, ONE, b), and
a proportional interpolation mul_div_i32(delta, elapsed, duration).
- Rounding: truncation toward zero, like Rust’s
/(so-7 * 1 / 2is-3, not-4). For floor semantics with a power-of-two divisor usemul_shr_i32. - Overflow: where the true quotient does not fit
i32the result wraps to its low 32 bits, exactly as theas i32cast above does (mul_div_i32(i32::MIN, -1, 1) == i32::MIN). Only that case pays a third native divide. c == 0: panics, like the 64-bit expression.
On the R3000A: one multu of the magnitudes, then a native divu when
the product fits 32 bits, else div_u64_by_u32 (two divu).