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.
Tuple Fields§
§0: u64
Implementations§
Source§impl Word
impl Word
Sourcepub fn iadd_cout_32(self, rhs: Word) -> (Word, Word)
pub fn iadd_cout_32(self, rhs: Word) -> (Word, Word)
Performs 32-bit addition.
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 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 fn shr_32(self, n: u32) -> Word
pub 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 fn sar(&self, n: u32) -> Word
pub 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 fn rotr_32(self, n: u32) -> Word
pub fn rotr_32(self, n: u32) -> Word
Rotate Right by a given number of bits followed by masking with a 32-bit mask.
Sourcepub fn imul(self, rhs: Word) -> (Word, Word)
pub 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 fn smul(self, rhs: Word) -> (Word, Word)
pub 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 fn wrapping_add(self, rhs: Word) -> Word
pub fn wrapping_add(self, rhs: Word) -> Word
Integer addition.
Wraps around on overflow.
Sourcepub fn wrapping_sub(self, rhs: Word) -> Word
pub fn wrapping_sub(self, rhs: Word) -> Word
Integer subtraction.
Wraps around on overflow.
Sourcepub fn is_msb_true(self) -> bool
pub 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 fn is_msb_false(self) -> bool
pub 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
Source§impl SerializeBytes for Word
impl SerializeBytes for Word
impl Copy for Word
impl Eq 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 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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