pub struct Uint<const N: usize> { /* private fields */ }Expand description
Stack-allocated big unsigned integer.
Generic over number N of Limbs.
Implementations§
Source§impl<const N: usize> Uint<N>
impl<const N: usize> Uint<N>
Sourcepub const fn new(limbs: [Limb; N]) -> Self
pub const fn new(limbs: [Limb; N]) -> Self
Create a new Uint from the provided limbs (constant).
Sourcepub const fn as_limbs(&self) -> &Limbs<N>
pub const fn as_limbs(&self) -> &Limbs<N>
Returns reference to the inner Limbs array (constant).
Sourcepub const fn into_limbs(self) -> Limbs<N>
pub const fn into_limbs(self) -> Limbs<N>
Returns inner Limbs array (constant).
Sourcepub const fn ge(&self, rhs: &Self) -> bool
pub const fn ge(&self, rhs: &Self) -> bool
Checks self is greater or equal then rhs (constant).
Sourcepub fn checked_mul2_assign(&mut self) -> bool
pub fn checked_mul2_assign(&mut self) -> bool
Multiplies self by 2 in-place, returning whether overflow occurred.
Sourcepub fn div2_assign(&mut self)
pub fn div2_assign(&mut self)
Divide self by 2 in-place.
Sourcepub const fn checked_sub(self, rhs: &Self) -> (Self, bool)
pub const fn checked_sub(self, rhs: &Self) -> (Self, bool)
Subtract rhs from self, returning the result and whether overflow
occurred (constant).
Sourcepub const fn wrapping_sub(&self, rhs: &Self) -> Self
pub const fn wrapping_sub(&self, rhs: &Self) -> Self
Subtract rhs from self, returning the result wrapping around the
lower boundary (constant).
Sourcepub const fn checked_add(self, rhs: &Self) -> (Self, bool)
pub const fn checked_add(self, rhs: &Self) -> (Self, bool)
Add rhs to self, returning the result and whether overflow occurred
(constant).
Sourcepub fn checked_add_assign(&mut self, rhs: &Self) -> bool
pub fn checked_add_assign(&mut self, rhs: &Self) -> bool
Add rhs to self in-place, returning whether overflow occurred.
Sourcepub fn checked_sub_assign(&mut self, rhs: &Self) -> bool
pub fn checked_sub_assign(&mut self, rhs: &Self) -> bool
Subtract rhs from self in-place, returning whether overflow
occurred.
Sourcepub const fn widening_mul(&self, rhs: &Self) -> (Self, Self)
pub const fn widening_mul(&self, rhs: &Self) -> (Self, Self)
Compute “wide” multiplication, with a product twice the size of the input.
Returns a tuple containing the (lo, hi) components of the product.
Basic multiplication algorithm described in wiki.
It is fast enough for runtime use when optimized with loop “unrolls”,
like const_for_unroll6.
Sourcepub const fn wrapping_add(&self, rhs: &Self) -> Self
pub const fn wrapping_add(&self, rhs: &Self) -> Self
Add two numbers wrapping around the upper boundary.
Sourcepub const fn adc(&self, rhs: &Uint<N>, carry: bool) -> (Self, bool)
pub const fn adc(&self, rhs: &Uint<N>, carry: bool) -> (Self, bool)
Computes a + b + carry, returning the result along with the new carry.
Sourcepub const fn from_le_slice(bytes: &[u8]) -> Self
pub const fn from_le_slice(bytes: &[u8]) -> Self
Create a new Uint from the provided little endian bytes.
Source§impl<const N: usize> Uint<N>
impl<const N: usize> Uint<N>
Sourcepub const fn from_usize(val: usize) -> Self
pub const fn from_usize(val: usize) -> Self
Create a Uint from
usize
integer (constant).
Trait Implementations§
Source§impl<const N: usize> BigInteger for Uint<N>
impl<const N: usize> BigInteger for Uint<N>
Source§impl<B: Borrow<Self>, const N: usize> BitAndAssign<B> for Uint<N>
impl<B: Borrow<Self>, const N: usize> BitAndAssign<B> for Uint<N>
Source§fn bitand_assign(&mut self, rhs: B)
fn bitand_assign(&mut self, rhs: B)
&= operation. Read moreSource§impl<const N: usize> BitIteratorBE for Uint<N>
impl<const N: usize> BitIteratorBE for Uint<N>
Source§fn bit_be_iter(self) -> impl Iterator<Item = bool>
fn bit_be_iter(self) -> impl Iterator<Item = bool>
Source§fn bit_be_trimmed_iter(self) -> impl Iterator<Item = bool>
fn bit_be_trimmed_iter(self) -> impl Iterator<Item = bool>
Source§impl<B: Borrow<Self>, const N: usize> BitOrAssign<B> for Uint<N>
impl<B: Borrow<Self>, const N: usize> BitOrAssign<B> for Uint<N>
Source§fn bitor_assign(&mut self, rhs: B)
fn bitor_assign(&mut self, rhs: B)
|= operation. Read moreSource§impl<B: Borrow<Self>, const N: usize> BitXorAssign<B> for Uint<N>
impl<B: Borrow<Self>, const N: usize> BitXorAssign<B> for Uint<N>
Source§fn bitxor_assign(&mut self, rhs: B)
fn bitxor_assign(&mut self, rhs: B)
^= operation. Read moreSource§impl<const N: usize> Ord for Uint<N>
impl<const N: usize> Ord for Uint<N>
Source§impl<const N: usize> PartialOrd for Uint<N>
impl<const N: usize> PartialOrd for Uint<N>
Source§impl<const N: usize> ShlAssign<u32> for Uint<N>
impl<const N: usize> ShlAssign<u32> for Uint<N>
Source§fn shl_assign(&mut self, rhs: u32)
fn shl_assign(&mut self, rhs: u32)
<<= operation. Read moreSource§impl<const N: usize> ShrAssign<u32> for Uint<N>
impl<const N: usize> ShrAssign<u32> for Uint<N>
Source§fn shr_assign(&mut self, rhs: u32)
fn shr_assign(&mut self, rhs: u32)
>>= operation. Read more