pub struct Wide(/* private fields */);Expand description
A signed 64-bit value, built from native 32-bit multiplies and adds.
See the module documentation for the operations it offers and the ones it leaves out on purpose.
Implementations§
Source§impl Wide
impl Wide
Sourcepub const fn from_parts(hi: i32, lo: u32) -> Wide
pub const fn from_parts(hi: i32, lo: u32) -> Wide
The value with signed high word hi and low word lo, the pair a
mult leaves in HI:LO.
Sourcepub const fn mul_sub(self, a: i32, b: i32) -> Wide
pub const fn mul_sub(self, a: i32, b: i32) -> Wide
self - a * b: one mult and a 64-bit subtract.
Sourcepub const fn mul_w(self, o: Wide) -> Wide
pub const fn mul_w(self, o: Wide) -> Wide
self * o, the low 64 bits of the product (three multiplies).
Sourcepub const fn unsigned_abs(self) -> WideU
pub const fn unsigned_abs(self) -> WideU
|self| as an unsigned value: exact for every input, Wide::MIN included
(2^63).
Sourcepub const fn cast_unsigned(self) -> WideU
pub const fn cast_unsigned(self) -> WideU
The same 64 bits read as unsigned, like as u64: a negative value becomes
2^64 - |self|.
Sourcepub const fn dot3(a: [i32; 3], b: [i32; 3]) -> Wide
pub const fn dot3(a: [i32; 3], b: [i32; 3]) -> Wide
The dot product of two 3-vectors, three mults and two 64-bit adds.
With a == b it is the squared length.
Sourcepub const fn sar(self, n: u32) -> Wide
pub const fn sar(self, n: u32) -> Wide
Arithmetic shift right (the sign is kept); the count is taken modulo 64.
Sourcepub const fn lshr(self, n: u32) -> Wide
pub const fn lshr(self, n: u32) -> Wide
Logical shift right of the 64-bit pattern (zeros come in at the top); the count is taken modulo 64.
Sourcepub const fn shr_i32(self, n: u32) -> i32
pub const fn shr_i32(self, n: u32) -> i32
self >> n (arithmetic, count modulo 64) truncated to its low 32
bits: the fixed-point “multiply, then drop the fraction” step.
Sourcepub const fn saturate_i32(self) -> i32
pub const fn saturate_i32(self) -> i32
The value clamped into i32.
Sourcepub const fn saturate_u32(self) -> u32
pub const fn saturate_u32(self) -> u32
The value clamped into u32 (a negative value gives 0).
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Is the value below zero?
Sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Is the value above zero?
Sourcepub const fn isqrt(self) -> u32
pub const fn isqrt(self) -> u32
floor(sqrt(self)), 0 for a negative value (crate::int32::isqrt_u64).
Source§impl Wide
impl Wide
Sourcepub const fn div_pow2(self, shift: u32) -> Wide
pub const fn div_pow2(self, shift: u32) -> Wide
self / 2^shift, truncated toward zero, for shift < 63: the bias and
arithmetic shift a compiler emits for i64 / (1 << shift).
Sourcepub fn div_i32_wrap(self, d: i32, round: Rounding) -> i32
pub fn div_i32_wrap(self, d: i32, round: Rounding) -> i32
self / d rounded as asked, as the low 32 bits of the quotient: where the
quotient does not fit i32 it wraps, exactly like (n / d) as i32.
Exact for every self and every nonzero d; panics if d is zero.
Sourcepub fn div_i32_sat(self, d: i32, round: Rounding) -> i32
pub fn div_i32_sat(self, d: i32, round: Rounding) -> i32
self / d rounded as asked and clamped to the i32 range. Panics if d is zero.
Sourcepub fn div_wide_sat(self, d: Wide, round: Rounding) -> i32
pub fn div_wide_sat(self, d: Wide, round: Rounding) -> i32
self / d for a wide divisor, rounded as asked and clamped to the i32 range.
Panics if d is zero.
Trait Implementations§
Source§impl Debug for Wide
Prints the two words, Wide(HI:LO) in hex. (Decimal formatting of 64 bits
would pull in a software divide.)
impl Debug for Wide
Prints the two words, Wide(HI:LO) in hex. (Decimal formatting of 64 bits
would pull in a software divide.)
Source§impl Ord for Wide
impl Ord for Wide
Source§impl PartialOrd for Wide
impl PartialOrd for Wide
impl Copy for Wide
impl Eq for Wide
impl StructuralPartialEq for Wide
Auto Trait Implementations§
impl Freeze for Wide
impl RefUnwindSafe for Wide
impl Send for Wide
impl Sync for Wide
impl Unpin for Wide
impl UnsafeUnpin for Wide
impl UnwindSafe for Wide
Blanket Implementations§
§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)