Skip to main content

ExactInt

Struct ExactInt 

Source
pub struct ExactInt { /* private fields */ }
Expand description

Arbitrary-precision signed integer. Distinct from ExactNum, which is floating-point.

Limbs are little-endian Words with no leading zeros. Zero is an empty limb vector and a positive sign.

Implementations§

Source§

impl ExactInt

Source

pub fn zero() -> ExactInt

The integer 0.

Source

pub fn one() -> ExactInt

The integer 1.

Source

pub fn from_u64(n: u64) -> ExactInt

Integer from u64.

Source

pub fn from_u128(n: u128) -> ExactInt

Integer from u128.

Source

pub fn from_i64(n: i64) -> ExactInt

Integer from i64.

Source

pub fn from_i128(n: i128) -> ExactInt

Integer from i128.

Source

pub fn is_zero(&self) -> bool

True if the value is 0.

Source

pub fn is_negative(&self) -> bool

True if the value is strictly negative.

Source

pub fn signum(&self) -> ExactInt

-1, 0, or +1.

Source

pub fn bit_length(&self) -> usize

Number of bits in |self|. Zero has bit length 0.

Source

pub fn cmp(&self, other: &ExactInt) -> Ordering

Compare as signed integers.

Source

pub fn add(&self, rhs: &ExactInt) -> ExactInt

self + rhs.

Source

pub fn sub(&self, rhs: &ExactInt) -> ExactInt

self - rhs.

Source

pub fn neg(&self) -> ExactInt

-self.

Source

pub fn mul(&self, rhs: &ExactInt) -> ExactInt

self * rhs.

Source

pub fn div_rem(&self, rhs: &ExactInt) -> Option<(ExactInt, ExactInt)>

Truncated division: (quotient, remainder) with remainder sign matching self. Zero divisor is None.

Source

pub fn gcd(&self, rhs: &ExactInt) -> ExactInt

Non-negative GCD. gcd(0, 0) = 0.

Source

pub fn pow(&self, exp: u64) -> ExactInt

self.pow(exp) by binary exponentiation. self^0 = 1.

Source

pub fn to_exact_num(&self, p: usize, rm: RoundingMode) -> ExactNum

Convert to an ExactNum at (p, rm).

Source

pub fn to_dec_string(&self) -> String

Decimal string of self (sign plus digits, no exponent).

Source

pub fn from_dec_string(s: &str) -> Option<ExactInt>

Parse a decimal integer string (-?[0-9]+). Empty or non-digits is None.

Source

pub fn from_exact_num(x: &ExactNum) -> Option<ExactInt>

Truncate a finite ExactNum toward zero. None if Inf or NaN.

Trait Implementations§

Source§

impl Clone for ExactInt

Source§

fn clone(&self) -> ExactInt

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExactInt

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for ExactInt

Source§

impl PartialEq for ExactInt

Source§

fn eq(&self, other: &ExactInt) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.