Struct sp_runtime::biguint::BigUint [−][src]
Simple wrapper around an infinitely large integer, represented as limbs of Single
.
Implementations
impl BigUint
[src]
pub fn with_capacity(size: usize) -> BigUint
[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: &[u32]) -> BigUint
[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) -> u32
[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<u32>
[src]
A naive getter for limb at index
. Note that the order is lsb -> msb.
pub fn set(&mut self, index: usize, value: u32)
[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) -> u32
[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) -> u32
[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: &BigUint) -> BigUint
[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: &BigUint) -> Result<BigUint, BigUint>
[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: &BigUint) -> BigUint
[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: u32) -> BigUint
[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: &BigUint, rem: bool) -> Option<(BigUint, BigUint)>
[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
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
impl Add<BigUint> for BigUint
[src]
type Output = BigUint
The resulting type after applying the +
operator.
pub fn add(self, rhs: BigUint) -> <BigUint as Add<BigUint>>::Output
[src]
impl Clone for BigUint
[src]
impl Debug for BigUint
[src]
impl Default for BigUint
[src]
impl Eq for BigUint
[src]
impl From<u16> for BigUint
[src]
impl From<u32> for BigUint
[src]
impl From<u64> for BigUint
[src]
impl From<u8> for BigUint
[src]
impl Mul<BigUint> for BigUint
[src]
type Output = BigUint
The resulting type after applying the *
operator.
pub fn mul(self, rhs: BigUint) -> <BigUint as Mul<BigUint>>::Output
[src]
impl Ord for BigUint
[src]
pub fn cmp(&self, other: &BigUint) -> Ordering
[src]
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<BigUint> for BigUint
[src]
pub fn eq(&self, other: &BigUint) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl PartialOrd<BigUint> for BigUint
[src]
pub fn partial_cmp(&self, other: &BigUint) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl Sub<BigUint> for BigUint
[src]
type Output = BigUint
The resulting type after applying the -
operator.
pub fn sub(self, rhs: BigUint) -> <BigUint as Sub<BigUint>>::Output
[src]
impl Zero 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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CheckedConversion for T
[src]
fn checked_from<T>(t: T) -> Option<Self> where
Self: TryFrom<T>,
[src]
Self: TryFrom<T>,
fn checked_into<T>(self) -> Option<T> where
Self: TryInto<T>,
[src]
Self: TryInto<T>,
impl<T> Clear for T where
T: PartialEq<T> + Eq + Default,
[src]
T: PartialEq<T> + Eq + Default,
impl<T> DynClone for T where
T: Clone,
[src]
T: Clone,
pub fn __clone_box(&self, Private) -> *mut ()
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, Outer> IsWrappedBy<Outer> for T where
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
[src]
T: From<Outer>,
Outer: AsRef<T> + AsMut<T> + From<T>,
pub fn from_ref(outer: &Outer) -> &T
[src]
Get a reference to the inner from the outer.
pub fn from_mut(outer: &mut Outer) -> &mut T
[src]
Get a mutable reference to the inner from the outer.
impl<T> MaybeDebug for T where
T: Debug,
[src]
T: Debug,
impl<T> MaybeDebug for T where
T: Debug,
[src]
T: Debug,
impl<T> MaybeRefUnwindSafe for T where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Member for T where
T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug,
[src]
T: 'static + Clone + PartialEq<T> + Eq + Send + Sync + Debug,
impl<T> Pointable for T
[src]
pub const ALIGN: usize
[src]
type Init = T
The type for initializers.
pub unsafe fn init(init: <T as Pointable>::Init) -> usize
[src]
pub unsafe fn deref<'a>(ptr: usize) -> &'a T
[src]
pub unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T
[src]
pub unsafe fn drop(ptr: usize)
[src]
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self
impl<T> SaturatedConversion for T
[src]
pub fn saturated_from<T>(t: T) -> Self where
Self: UniqueSaturatedFrom<T>,
[src]
Self: UniqueSaturatedFrom<T>,
pub fn saturated_into<T>(self) -> T where
Self: UniqueSaturatedInto<T>,
[src]
Self: UniqueSaturatedInto<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<S, T> UncheckedInto<T> for S where
T: UncheckedFrom<S>,
[src]
T: UncheckedFrom<S>,
pub fn unchecked_into(self) -> T
[src]
impl<T, S> UniqueSaturatedInto<T> for S where
T: Bounded,
S: TryInto<T>,
[src]
T: Bounded,
S: TryInto<T>,
pub fn unique_saturated_into(self) -> T
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,