pub struct Tight<const BASE: usize> { /* private fields */ }Expand description
A tightly-packed arbitrary base big int implementation. Supports any base from 2-u64::MAX.
In this implementation, bits are tightly packed against one another,
requiring only ceil(log_2(BASE)) bits per digit. Signficiantly more space-efficient for
smaller bases compared to the loose implementation. However, the extra indirection contributes
to some added overhead.
use big_int::prelude::*;
let a: TightInt<10> = 593.into();
let b = a * 96.into();
assert_eq!(b, 56928.into());Trait Implementations§
source§impl<const BASE: usize> BigIntImplementation<BASE> for Tight<BASE>
impl<const BASE: usize> BigIntImplementation<BASE> for Tight<BASE>
type Builder = TightBuilder<BASE>
type DigitIterator<'a> = TightIter<'a, BASE>
source§fn get_digit(&self, digit: usize) -> Option<Digit>
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)
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 push_back(&mut self, digit: Digit)
fn push_back(&mut self, digit: Digit)
Append a digit to the right side of the int. Equivalent to
(int << 1) + digitsource§unsafe fn push_front(&mut self, digit: Digit)
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 shr_assign(&mut self, amount: usize)
fn shr_assign(&mut self, amount: usize)
Divide the int by BASE^amount in place. Read more
source§fn shl_assign(&mut self, amount: usize)
fn shl_assign(&mut self, amount: usize)
Multiply the int by BASE^amount in place. Read more
fn iter<'a>(&'a self) -> Self::DigitIterator<'a>
source§fn normalized(self) -> Self
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. Read more
source§fn normalize(&mut self)
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. Read moresource§impl<const BASE: usize> From<TightBuilder<BASE>> for Tight<BASE>
impl<const BASE: usize> From<TightBuilder<BASE>> for Tight<BASE>
source§fn from(builder: TightBuilder<BASE>) -> Self
fn from(builder: TightBuilder<BASE>) -> Self
Converts to this type from the input type.
source§impl<const BASE: usize> PartialEq for Tight<BASE>
impl<const BASE: usize> PartialEq for Tight<BASE>
impl<const BASE: usize> Eq for Tight<BASE>
impl<const BASE: usize> StructuralEq for Tight<BASE>
impl<const BASE: usize> StructuralPartialEq for Tight<BASE>
Auto Trait Implementations§
impl<const BASE: usize> RefUnwindSafe for Tight<BASE>
impl<const BASE: usize> Send for Tight<BASE>
impl<const BASE: usize> Sync for Tight<BASE>
impl<const BASE: usize> Unpin for Tight<BASE>
impl<const BASE: usize> UnwindSafe for Tight<BASE>
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