pub struct DownDivisorU32 {
divisor: u32,
multiplier: u32,
shift: u32,
}Expand description
A u32 divisor whose rounded-up multiplier isn’t exact in N bits, see DivisorU32
It computes MULUH(m, n + 1) >> shift with the rounded-down multiplier
m = floor(2^(N+shift) / divisor), from
ridiculous_fish, “Labor of Division (Episode III)”.
The increment saturates, so u32::MAX gives the quotient of u32::MAX - 1. The two are
equal unless the divisor divides 2^N - 1, and those divisors always have an exact
rounded-up multiplier, as the post proves, so they never use this type.
DivisorU32::new returns it only on aarch64 and on x86 with SSE4.1, so the example
checks nothing on other targets.
Fields§
§divisor: u32§multiplier: u32§shift: u32Implementations§
Trait Implementations§
Source§impl Clone for DownDivisorU32
impl Clone for DownDivisorU32
impl Copy for DownDivisorU32
Auto Trait Implementations§
impl Forget for DownDivisorU32
impl Freeze for DownDivisorU32
impl Move for DownDivisorU32
impl RefUnwindSafe for DownDivisorU32
impl Send for DownDivisorU32
impl Sync for DownDivisorU32
impl Unpin for DownDivisorU32
impl UnsafeUnpin for DownDivisorU32
impl UnwindSafe for DownDivisorU32
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more