pub trait BigIntImplementation<const BASE: usize>
where Self: Clone + PartialEq + Eq + Debug,
{ type Builder: BigIntBuilder<{ BASE }> + Build<Self>; type DigitIterator<'a>: DoubleEndedIterator<Item = Digit> where Self: 'a;
Show 18 methods // Required methods fn len(&self) -> usize; fn get_digit(&self, digit: usize) -> Option<Digit>; fn set_digit(&mut self, digit: usize, value: Digit); fn zero() -> Self; fn sign(&self) -> Sign; fn with_sign(self, sign: Sign) -> Self; fn set_sign(&mut self, sign: Sign); fn push_back(&mut self, digit: Digit); unsafe fn push_front(&mut self, digit: Digit); fn iter<'a>(&'a self) -> Self::DigitIterator<'a>; // Provided methods fn shr(self, amount: usize) -> Self { ... } fn shr_assign(&mut self, amount: usize) { ... } fn shl(self, amount: usize) -> Self { ... } fn shl_assign(&mut self, amount: usize) { ... } fn normalized(self) -> Self { ... } fn normalize(&mut self) { ... } fn display(&self, alphabet: &str) -> Result<String, BigIntError> { ... } fn parse(value: &str, alphabet: &str) -> Result<Self, ParseError> { ... }
}

Required Associated Types§

source

type Builder: BigIntBuilder<{ BASE }> + Build<Self>

source

type DigitIterator<'a>: DoubleEndedIterator<Item = Digit> where Self: 'a

Required Methods§

source

fn len(&self) -> usize

The length of the big int.

source

fn get_digit(&self, digit: usize) -> Option<Digit>

Get the digit of the big int at position digit, or None if the number does not have that many digits / the digit is negative.

source

fn set_digit(&mut self, digit: usize, value: Digit)

Set the digit of the big int to value at position digit. Return Some(Digit) of the digit’s existing value, or None if no digit was set.

source

fn zero() -> Self

The constant zero represented as a big int.

source

fn sign(&self) -> Sign

The sign of the big int.

source

fn with_sign(self, sign: Sign) -> Self

The big int with the desired parity of sign.

source

fn set_sign(&mut self, sign: Sign)

Set the sign of the big int to sign.

source

fn push_back(&mut self, digit: Digit)

Append a digit to the right side of the int. Equivalent to (int << 1) + digit

source

unsafe fn push_front(&mut self, digit: Digit)

Append a digit to the left side of the int. Will denormalize if the appended digit is a zero; make sure to call .normalize() afterwards to prevent undefined functionality.

source

fn iter<'a>(&'a self) -> Self::DigitIterator<'a>

Provided Methods§

source

fn shr(self, amount: usize) -> Self

Divide the int by BASE^amount.

Note: works in powers of BASE, not in powers of 2.

Defined in terms of shr_assign; exactly one of shr or shr_assign must be defined.

source

fn shr_assign(&mut self, amount: usize)

Divide the int by BASE^amount in place.

Note: works in powers of BASE, not in powers of 2.

Defined in terms of shr; exactly one of shr or shr_assign must be defined.

source

fn shl(self, amount: usize) -> Self

Multiply the int by BASE^amount.

Note: works in powers of BASE, not in powers of 2.

Defined in terms of shl_assign; exactly one of shl or shl_assign must be defined.

source

fn shl_assign(&mut self, amount: usize)

Multiply the int by BASE^amount in place.

Note: works in powers of BASE, not in powers of 2.

Defined in terms of shl; exactly one of shl or shl_assign must be defined.

source

fn normalized(self) -> Self

Return a normalized version of the int. Remove trailing zeros, and disable the parity flag if the resulting number is zero.

use big_int::prelude::*;

let n = BigInt::from(unsafe { Loose::<10>::from_raw_parts(vec![0, 0, 8, 3]) });
assert_eq!(n.normalized(), 83.into());
source

fn normalize(&mut self)

Normalize a Loose big int in place. Remove trailing zeros, and disable the parity flag if the resulting number is zero.

use big_int::prelude::*;

let mut n = BigInt::from(unsafe { Loose::<10>::from_raw_parts(vec![0, 0, 8, 3]) });
n.normalize();
assert_eq!(n, 83.into());
source

fn display(&self, alphabet: &str) -> Result<String, BigIntError>

Convert a big int to a printable string using the provided alphabet alphabet. Display uses this method with the default alphabet STANDARD_ALPHABET.

use big_int::prelude::*;

assert_eq!(
    LooseInt::<10>::from(6012).display(STANDARD_ALPHABET).unwrap(),
    "6012".to_string()
);
source

fn parse(value: &str, alphabet: &str) -> Result<Self, ParseError>

Parse a Loose big int from a value: &str, referencing the provided alphabet to determine what characters represent which digits. FromStr uses this method with the default alphabet STANDARD_ALPHABET.

use big_int::prelude::*;

assert_eq!(LooseInt::parse("125", STANDARD_ALPHABET), Ok(LooseInt::<10>::from(125)));

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<const BASE: usize> BigIntImplementation<BASE> for Loose<BASE>

§

type Builder = LooseBuilder<BASE>

§

type DigitIterator<'a> = LooseIter<'a, BASE>

source§

impl<const BASE: usize> BigIntImplementation<BASE> for Tight<BASE>

§

type Builder = TightBuilder<BASE>

§

type DigitIterator<'a> = TightIter<'a, BASE>