#[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
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 as_usize(&self) -> usize
pub fn as_usize(&self) -> usize
Conversion to usize with overflow checking
§Panics
Panics if the number is larger than usize::max_value().
Sourcepub fn index(&self, index: usize) -> u8
pub fn index(&self, index: usize) -> u8
Return specific byte in big-endian format.
§Panics
Panics if index
exceeds the byte width of the number.
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.