Struct sp_arithmetic::biguint::BigUint [−][src]
pub struct BigUint { /* fields omitted */ }
Expand description
Simple wrapper around an infinitely large integer, represented as limbs of Single
.
Implementations
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.
Raw constructor from custom limbs. If limbs
is empty, Zero::zero()
implementation is
used.
A naive getter for limb at index
. Note that the order is lsb -> msb.
Panics
This panics if index is out of range.
A naive getter for limb at index
. Note that the order is lsb -> msb.
A naive setter for limb at index
. Note that the order is lsb -> msb.
Panics
This panics if index is out of range.
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.
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.
Strips zeros from the left side (the most significant limbs) of self
, if any.
Zero-pad self
from left to reach size
limbs. Will not make any difference if self
is already bigger than size
limbs.
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.
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.
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.
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.
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
other
to be stripped and have no leading zeros. - requires
self
to be stripped and have no leading zeros. - requires
other
to have at least two limbs. - requires
self
to 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
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
fn encoded_fixed_size() -> Option<usize>
fn encoded_fixed_size() -> Option<usize>
Returns the fixed encoded size of the type. Read more
Convert self to a slice and append it to the destination.
Convert self to a slice and then invoke the given closure with it.
fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for BigUint
impl UnwindSafe for BigUint
Blanket Implementations
Mutably borrows from an owned value. Read more
Consume self to return an equivalent value of T
.
impl<'_, '_, T> EncodeLike<&'_ &'_ T> for T where
T: Encode,
impl<'_, T> EncodeLike<&'_ T> for T where
T: Encode,
impl<'_, T> EncodeLike<&'_ mut T> for T where
T: Encode,
impl<T> EncodeLike<Arc<T>> for T where
T: Encode,
impl<T> EncodeLike<Rc<T>> for T where
T: Encode,