Struct sp_arithmetic::biguint::BigUint [−][src]
pub struct BigUint { /* fields omitted */ }Simple wrapper around an infinitely large integer, represented as limbs of Single.
Implementations
impl BigUint[src]
impl BigUint[src]pub fn with_capacity(size: usize) -> Self[src]
Create a new instance with size limbs. This prevents any number with zero limbs to be
created.
The behavior of the type is undefined with zero limbs.
pub fn from_limbs(limbs: &[Single]) -> Self[src]
Raw constructor from custom limbs. If limbs is empty, Zero::zero() implementation is
used.
pub fn len(&self) -> usize[src]
Number of limbs.
pub fn get(&self, index: usize) -> Single[src]
A naive getter for limb at index. Note that the order is lsb -> msb.
Panics
This panics if index is out of range.
pub fn checked_get(&self, index: usize) -> Option<Single>[src]
A naive getter for limb at index. Note that the order is lsb -> msb.
pub fn set(&mut self, index: usize, value: Single)[src]
A naive setter for limb at index. Note that the order is lsb -> msb.
Panics
This panics if index is out of range.
pub fn lsb(&self) -> Single[src]
returns the least significant limb of the number.
Panics
While the constructor of the type prevents this, this can panic if self has no digits.
pub fn msb(&self) -> Single[src]
returns the most significant limb of the number.
Panics
While the constructor of the type prevents this, this can panic if self has no digits.
pub fn lstrip(&mut self)[src]
Strips zeros from the left side (the most significant limbs) of self, if any.
pub fn lpad(&mut self, size: usize)[src]
Zero-pad self from left to reach size limbs. Will not make any difference if self
is already bigger than size limbs.
pub fn add(self, other: &Self) -> Self[src]
Adds self with other. self and other do not have to have any particular size. Given
that the n = max{size(self), size(other)}, it will produce a number with n + 1
limbs.
This function does not strip the output and returns the original allocated n + 1
limbs. The caller may strip the output if desired.
Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.
pub fn sub(self, other: &Self) -> Result<Self, Self>[src]
Subtracts other from self. self and other do not have to have any particular size.
Given that the n = max{size(self), size(other)}, it will produce a number of size n.
If other is bigger than self, Err(B - borrow) is returned.
Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.
pub fn mul(self, other: &Self) -> Self[src]
Multiplies n-limb number self with m-limb number other.
The resulting number will always have n + m limbs.
This function does not strip the output and returns the original allocated n + m
limbs. The caller may strip the output if desired.
Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.
pub fn div_unit(self, other: Single) -> Self[src]
Divides self by a single limb other. This can be used in cases where the original
division cannot work due to the divisor (other) being just one limb.
Invariant: other cannot be zero.
pub fn div(self, other: &Self, rem: bool) -> Option<(Self, Self)>[src]
Divides an n + m limb self by a n limb other. The result is a m + 1 limb
quotient and a n limb remainder, if enabled by passing true in rem argument, both
in the form of an option’s Ok.
- requires
otherto be stripped and have no leading zeros. - requires
selfto be stripped and have no leading zeros. - requires
otherto have at least two limbs. - requires
selfto have a greater length compared toother.
All arguments are examined without being stripped for the above conditions. If any of
the above fails, None is returned.`
Taken from “The Art of Computer Programming” by D.E. Knuth, vol 2, chapter 4.
Trait Implementations
impl PartialOrd<BigUint> for BigUint[src]
impl PartialOrd<BigUint> for BigUint[src]impl Eq for BigUint[src]
Auto Trait Implementations
impl RefUnwindSafe for BigUint
impl Send for BigUint
impl Sync for BigUint
impl Unpin for BigUint
impl UnwindSafe for BigUint
Blanket Implementations
impl<T> SaturatedConversion for T[src]
impl<T> SaturatedConversion for T[src]fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>, [src]
Self: UniqueSaturatedFrom<T>,
fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>, [src]
Self: UniqueSaturatedInto<T>,
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>, [src]
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>, [src]