pub(crate) struct Nat {
limbs: Vec<u32>,
}Expand description
A natural number (the chapter).
Fields§
§limbs: Vec<u32>Base-2³² digits, least significant first, no leading zero (N1).
Implementations§
Source§impl Nat
impl Nat
Sourcepub(crate) fn from_decimal_digits(digits: &[u8]) -> Self
pub(crate) fn from_decimal_digits(digits: &[u8]) -> Self
The value of a string of decimal digits (bytes 0..=9, most
significant first).
Sourcepub(crate) fn div_rem_small(&mut self, d: u32) -> u32
pub(crate) fn div_rem_small(&mut self, d: u32) -> u32
N ← ⌊N / d⌋, returning N mod d; d > 0.
Sourcepub(crate) fn split_at_bit(&self, s: u64) -> (Self, Self)
pub(crate) fn split_at_bit(&self, s: u64) -> (Self, Self)
(⌊N / 2ˢ⌋, N mod 2ˢ).
Sourcepub(crate) fn short_quotient(&self, den: &Self) -> (u128, bool)
pub(crate) fn short_quotient(&self, den: &Self) -> (u128, bool)
Algorithm Q: (⌊N / D⌋, N mod D ≠ 0); requires D > 0 and a
quotient below 2¹²⁸.
Sourcepub(crate) fn to_decimal_digits(&self) -> Vec<u8> ⓘ
pub(crate) fn to_decimal_digits(&self) -> Vec<u8> ⓘ
The decimal digits (bytes 0..=9), most significant first; empty
for zero.
Trait Implementations§
impl Eq for Nat
Source§impl Ord for Nat
impl Ord for Nat
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Nat
impl PartialOrd for Nat
impl StructuralPartialEq for Nat
Auto Trait Implementations§
impl Freeze for Nat
impl RefUnwindSafe for Nat
impl Send for Nat
impl Sync for Nat
impl Unpin for Nat
impl UnsafeUnpin for Nat
impl UnwindSafe for Nat
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
Mutably borrows from an owned value. Read more