#[repr(transparent)]pub struct Word(pub u64);Expand description
Word is 64-bit value and is a fundamental unit of data in Binius64. All computation and
constraints operate on it.
The transparent layout matches the inner 64-bit integer exactly. That lets slices of words be reinterpreted as raw bytes, and back, for zero-copy bulk copies.
Tuple Fields§
§0: u64Implementations§
Source§impl Word
impl Word
Sourcepub const fn extract_bit(self, i: usize) -> bool
pub const fn extract_bit(self, i: usize) -> bool
Returns the bit at position i, counting from the least significant bit.
i must be in 0..64.
Sourcepub const fn iadd32_cin_cout(self, rhs: Word, cin: Word) -> (Word, Word)
pub const fn iadd32_cin_cout(self, rhs: Word, cin: Word) -> (Word, Word)
Performs parallel 32-bit additions on the upper and lower halves with carry-in.
Each 32-bit half is added independently, like sll32 operates on
independent halves. The carry-in for the lower half is taken from bit 31 of cin,
and the carry-in for the upper half is taken from bit 63 of cin.
Returns (sum, carry_out) where the ith carry_out bit is set to one if there is a carry out at that bit position.
Sourcepub const fn iadd_cout_32(self, rhs: Word) -> (Word, Word)
pub const fn iadd_cout_32(self, rhs: Word) -> (Word, Word)
Performs parallel 32-bit additions on the upper and lower halves.
Equivalent to iadd32_cin_cout with zero carry-in.
Sourcepub fn iadd_cin_cout(self, rhs: Word, cin: Word) -> (Word, Word)
pub fn iadd_cin_cout(self, rhs: Word, cin: Word) -> (Word, Word)
Performs 64-bit addition with carry input bit.
cin is a carry-in from the previous addition. Since it can only affect the LSB only, the cin could be 1 if there is carry over, or 0 otherwise.
Returns (sum, carry_out) where ith carry_out bit is set to one if there is a carry out at that bit position.
Sourcepub fn isub_bin_bout(self, rhs: Word, bin: Word) -> (Word, Word)
pub fn isub_bin_bout(self, rhs: Word, bin: Word) -> (Word, Word)
Performs 64-bit subtraction with borrow input bit.
bin is a borrow-in from the previous subtraction. Since it can only affect the LSB only, the bin could be 1 if there is borrow over, or 0 otherwise.
Returns (diff, borrow_out) where ith borrow_out bit is set to one if there is a borrow out at that bit position.
Sourcepub const fn shr_32(self, n: u32) -> Word
pub const fn shr_32(self, n: u32) -> Word
Performs shift right by a given number of bits followed by masking with a 32-bit mask.
Sourcepub const fn sar(self, n: u32) -> Word
pub const fn sar(self, n: u32) -> Word
Shift Arithmetic Right by a given number of bits.
This is similar to a logical shift right, but it shifts the sign bit to the right.
Sourcepub const fn sll32(self, n: u32) -> Word
pub const fn sll32(self, n: u32) -> Word
Shift Left Logical on 32-bit halves.
Performs independent logical left shifts on the upper and lower 32-bit halves. Only uses the lower 5 bits of the shift amount (0-31).
Sourcepub const fn srl32(self, n: u32) -> Word
pub const fn srl32(self, n: u32) -> Word
Shift Right Logical on 32-bit halves.
Performs independent logical right shifts on the upper and lower 32-bit halves. Only uses the lower 5 bits of the shift amount (0-31).
Sourcepub const fn sra32(self, n: u32) -> Word
pub const fn sra32(self, n: u32) -> Word
Shift Right Arithmetic on 32-bit halves.
Performs independent arithmetic right shifts on the upper and lower 32-bit halves. Sign extends each 32-bit half independently. Only uses the lower 5 bits of the shift amount (0-31).
Sourcepub const fn rotr32(self, n: u32) -> Word
pub const fn rotr32(self, n: u32) -> Word
Rotate Right on 32-bit halves.
Performs independent rotate right operations on the upper and lower 32-bit halves. Bits shifted off the right end wrap around to the left within each 32-bit half. Only uses the lower 5 bits of the shift amount (0-31).
Sourcepub const fn imul(self, rhs: Word) -> (Word, Word)
pub const fn imul(self, rhs: Word) -> (Word, Word)
Unsigned integer multiplication.
Multiplies two 64-bit unsigned integers and returns the 128-bit result split into high and low 64-bit words, respectively.
Sourcepub const fn smul(self, rhs: Word) -> (Word, Word)
pub const fn smul(self, rhs: Word) -> (Word, Word)
Signed integer multiplication.
Multiplies two 64-bit signed integers and returns the 128-bit result split into high and low 64-bit words, respectively.
Sourcepub const fn wrapping_add(self, rhs: Word) -> Word
pub const fn wrapping_add(self, rhs: Word) -> Word
Integer addition.
Wraps around on overflow.
Sourcepub const fn wrapping_sub(self, rhs: Word) -> Word
pub const fn wrapping_sub(self, rhs: Word) -> Word
Integer subtraction.
Wraps around on overflow.
Sourcepub const fn is_msb_true(self) -> bool
pub const fn is_msb_true(self) -> bool
Tests if this Word represents true as an MSB-bool.
In MSB-bool representation, a value is true if its Most Significant Bit (bit 63) is set to
- All other bits are ignored for the boolean value.
Returns true if the MSB is 1, false otherwise.
Sourcepub const fn is_msb_false(self) -> bool
pub const fn is_msb_false(self) -> bool
Tests if this Word represents false as an MSB-bool.
In MSB-bool representation, a value is false if its Most Significant Bit (bit 63) is 0. All other bits are ignored for the boolean value.
Returns true if the MSB is 0, false otherwise.
Trait Implementations§
Source§impl DeserializeBytes for Word
impl DeserializeBytes for Word
fn deserialize(read_buf: impl Buf) -> Result<Self, SerializationError>where
Self: Sized,
Source§impl Ord for Word
impl Ord for Word
Source§impl PartialOrd for Word
impl PartialOrd for Word
impl Copy for Word
impl Eq for Word
impl Pod for Word
impl StructuralPartialEq for Word
Auto Trait Implementations§
impl Freeze for Word
impl RefUnwindSafe for Word
impl Send for Word
impl Sync for Word
impl Unpin for Word
impl UnsafeUnpin for Word
impl UnwindSafe for Word
Blanket Implementations§
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
§impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more