pub struct Int(/* private fields */);Expand description
An integer, with no bound.
Addition, subtraction, multiplication and negation are exact and never
fault. Integer division rounds toward negative infinity and % is the
matching remainder, so for every nonzero b,
a == a.div(b) * b + a.rem(b) with the remainder zero or carrying b’s
sign. A zero divisor is the one fault.
The derived order is the order of the numbers, which is data.md’s.
Implementations§
Source§impl Int
impl Int
Sourcepub fn from_limbs(limbs: &[u32]) -> Self
pub fn from_limbs(limbs: &[u32]) -> Self
Returns the nonnegative integer whose magnitude is limbs,
little-endian base 2^32: what a decoded literal holds, read in
O(limbs).
Sourcepub fn parse(digits: &str) -> Option<Self>
pub fn parse(digits: &str) -> Option<Self>
Returns the integer ASCII decimal digits with an optional leading -
spell. +, separators, whitespace and other radixes are refused.
Sourcepub fn div(&self, divisor: &Int) -> Result<Int, Fault>
pub fn div(&self, divisor: &Int) -> Result<Int, Fault>
Returns self.div(divisor): the quotient rounded toward negative
infinity.
§Errors
Fault::DivisionByZero for a zero divisor.
Sourcepub fn rem(&self, divisor: &Int) -> Result<Int, Fault>
pub fn rem(&self, divisor: &Int) -> Result<Int, Fault>
Returns self % divisor: the remainder matching Int::div, zero or
carrying the divisor’s sign.
§Errors
Fault::DivisionByZero for a zero divisor.
Sourcepub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> bool
Returns whether this is below zero.
Sourcepub fn bits(&self) -> u64
pub fn bits(&self) -> u64
Returns how many bits the magnitude takes, the sign excluded: 0 for
zero, 1 for 1 and -1, and 4096 for 2^4096 - 1.
Sourcepub fn to_index(&self) -> Option<usize>
pub fn to_index(&self) -> Option<usize>
Returns this as a zero-based position, or None for a negative one or
one no in-memory sequence could reach.
Sourcepub fn from_count(count: usize) -> Int
pub fn from_count(count: usize) -> Int
Returns a count — a length or a position — as an integer.
Trait Implementations§
Source§impl Display for Int
The text form: decimal digits, - before a negative number, no leading
zero (data.md, Int).
impl Display for Int
The text form: decimal digits, - before a negative number, no leading
zero (data.md, Int).