#[repr(C)]pub struct U512(pub [u64; 8]);
Expand description
Little-endian large integer type
Tuple Fields§
§0: [u64; 8]
Implementations§
Source§impl U512
impl U512
pub const MAX: U512
Sourcepub fn from_dec_str(value: &str) -> Result<Self, FromDecStrErr>
pub fn from_dec_str(value: &str) -> Result<Self, FromDecStrErr>
Convert from a decimal string.
Sourcepub fn leading_zeros(&self) -> u32
pub fn leading_zeros(&self) -> u32
Returns the number of leading zeros in the binary representation of self.
Sourcepub fn trailing_zeros(&self) -> u32
pub fn trailing_zeros(&self) -> u32
Returns the number of leading zeros in the binary representation of self.
Sourcepub fn to_big_endian(&self, bytes: &mut [u8])
pub fn to_big_endian(&self, bytes: &mut [u8])
Write to the slice in big-endian format.
Sourcepub fn to_little_endian(&self, bytes: &mut [u8])
pub fn to_little_endian(&self, bytes: &mut [u8])
Write to the slice in little-endian format.
Sourcepub fn pow(self, expon: Self) -> Self
pub fn pow(self, expon: Self) -> Self
Fast exponentation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring
§Panics
Panics if the result overflows the type.
Sourcepub fn overflowing_pow(self, expon: Self) -> (Self, bool)
pub fn overflowing_pow(self, expon: Self) -> (Self, bool)
Fast exponentation by squaring https://en.wikipedia.org/wiki/Exponentiation_by_squaring
Sourcepub fn overflowing_add(self, other: U512) -> (U512, bool)
pub fn overflowing_add(self, other: U512) -> (U512, bool)
Optimized instructions
Sourcepub fn saturating_add(self, other: U512) -> U512
pub fn saturating_add(self, other: U512) -> U512
Addition which saturates at the maximum value.
Sourcepub fn overflowing_sub(self, other: U512) -> (U512, bool)
pub fn overflowing_sub(self, other: U512) -> (U512, bool)
Subtraction which underflows and returns a flag if it does.
Sourcepub fn saturating_sub(self, other: U512) -> U512
pub fn saturating_sub(self, other: U512) -> U512
Subtraction which saturates at zero.
Sourcepub fn overflowing_mul(self, other: U512) -> (U512, bool)
pub fn overflowing_mul(self, other: U512) -> (U512, bool)
Multiply with overflow, returning a flag if it does.
Sourcepub fn saturating_mul(self, other: U512) -> U512
pub fn saturating_mul(self, other: U512) -> U512
Multiplication which saturates at the maximum value..
Sourcepub fn overflowing_div(self, other: U512) -> (U512, bool)
pub fn overflowing_div(self, other: U512) -> (U512, bool)
Division with overflow
Sourcepub fn overflowing_rem(self, other: U512) -> (U512, bool)
pub fn overflowing_rem(self, other: U512) -> (U512, bool)
Modulus with overflow.
Sourcepub fn overflowing_neg(self) -> (U512, bool)
pub fn overflowing_neg(self) -> (U512, bool)
Negation with overflow.
Sourcepub fn from_big_endian(slice: &[u8]) -> Self
pub fn from_big_endian(slice: &[u8]) -> Self
Converts from big endian representation bytes in memory
Can also be used as (&slice).into(), as it is default From
slice implementation for U256
Sourcepub fn from_little_endian(slice: &[u8]) -> Self
pub fn from_little_endian(slice: &[u8]) -> Self
Converts from little endian representation bytes in memory