pub struct WideU(/* private fields */);Expand description
An unsigned 64-bit value: a u32 * u32 product needs all 64 bits.
Same rules as Wide: native operations only; division is in crate::wide_div.
Implementations§
Source§impl WideU
impl WideU
Sourcepub const fn from_parts(hi: u32, lo: u32) -> WideU
pub const fn from_parts(hi: u32, lo: u32) -> WideU
The value with high word hi and low word lo, the pair a multu
leaves in HI:LO.
Sourcepub const fn mul_add(self, a: u32, b: u32) -> WideU
pub const fn mul_add(self, a: u32, b: u32) -> WideU
self + a * b: one multu and a 64-bit add (wrapping).
Sourcepub const fn saturating_add(self, o: WideU) -> WideU
pub const fn saturating_add(self, o: WideU) -> WideU
self + o, stopping at WideU::MAX.
Sourcepub const fn shr_by(self, n: u32) -> WideU
pub const fn shr_by(self, n: u32) -> WideU
Shift right (zeros come in at the top); the count is taken modulo 64.
Sourcepub const fn shr_u32(self, n: u32) -> u32
pub const fn shr_u32(self, n: u32) -> u32
self >> n (count modulo 64) truncated to its low 32 bits.
Sourcepub const fn saturate_u32(self) -> u32
pub const fn saturate_u32(self) -> u32
The value clamped into u32.
Sourcepub const fn cast_signed(self) -> Wide
pub const fn cast_signed(self) -> Wide
The same 64 bits read as signed, like as i64: a value from 2^63 up becomes
negative.
Sourcepub const fn isqrt(self) -> u32
pub const fn isqrt(self) -> u32
floor(sqrt(self)) (crate::int32::isqrt_u64).
Source§impl WideU
impl WideU
Sourcepub fn div_rem_u32(self, d: u32) -> (WideU, u32)
pub fn div_rem_u32(self, d: u32) -> (WideU, u32)
(self / d, self % d): the exact 64-bit quotient and the remainder.
A numerator below 2^32 is one divu. Panics if d is zero.
Sourcepub fn quotient(self, d: WideU) -> u32
pub fn quotient(self, d: WideU) -> u32
floor(self / d), clamped to u32::MAX when the true quotient is
larger. Exact: no estimate survives to the result. Panics if d is zero.
A divisor wider than 32 bits makes the quotient fit u32 by itself; the
clamp only matters for a divisor that fits 32 bits.
Sourcepub fn mul_full(self, o: WideU) -> (WideU, WideU)
pub fn mul_full(self, o: WideU) -> (WideU, WideU)
The exact 128-bit product of two values, as (bits 64..128, bits 0..64).
Sourcepub fn cmp_ratio(a: WideU, b: WideU, c: WideU, d: WideU) -> Ordering
pub fn cmp_ratio(a: WideU, b: WideU, c: WideU, d: WideU) -> Ordering
Orders a / b against c / d without dividing: a * d against c * b,
each an exact 128-bit product. b and d must be nonzero.
Sourcepub fn scale_by_ratio(self, a: u32, den: WideU) -> u32
pub fn scale_by_ratio(self, a: u32, den: WideU) -> u32
floor(a * self / den) for self <= den (a fraction of at most one), so the
result is at most a. Exact. Panics if den is zero or self > den.