Expand description
Total integer arithmetic: the operations that cannot overflow.
Every function here returns an Option, and None is exactly the case the
machine’s +/-/* would have wrapped (or, in debug, panicked). crate::prove
carries the proof that the flag is exact rather than a heuristic.
Functions§
- checked_
add a + b, orNoneon overflow. Total: no panic, no wrap-around.- checked_
mul a * b, orNoneon overflow.- checked_
sub a - b, orNoneon underflow.- mul_div
a * b / dwithout overflow in the intermediate product, using a 64-bit widening. ReturnsNonewhend == 0or the true quotient exceedsu32.- saturating_
add a + b, clamped to the type’s maximum.- saturating_
sub a - b, clamped at zero.