Struct Big32x40
pub struct Big32x40 { pub(in ::num::imp::bignum) size: usize, pub(in ::num::imp::bignum) base: [Digit32; 40] }
Stack-allocated arbitrary-precision (up to certain limit) integer.
This is backed by a fixed-size array of given type ("digit").
While the array is not very large (normally some hundred bytes),
copying it recklessly may result in the performance hit.
Thus this is intentionally not Copy.
All operations available to bignums panic in the case of overflows. The caller is responsible to use large enough bignum types.
Fields
size: usizeOne plus the offset to the maximum "digit" in use. This does not decrease, so be aware of the computation order.
base[size..]should be zero.base: [Digit32; 40]Digits.
[a, b, c, ...]representsa + b*2^W + c*2^(2W) + ...whereWis the number of bits in the digit type.
Implementations
impl Big32x40
fn from_small(v: Digit32) -> Big32x40Makes a bignum from one digit.
fn from_u64(v: u64) -> Big32x40Makes a bignum from
u64value.fn digits(&self) -> &[Digit32]Returns the internal digits as a slice
[a, b, c, ...]such that the numeric value isa + b * 2^W + c * 2^(2W) + ...whereWis the number of bits in the digit type.fn get_bit(&self, i: usize) -> u8Returns the
i-th bit where bit 0 is the least significant one. In other words, the bit with weight2^i.fn is_zero(&self) -> boolReturns
trueif the bignum is zero.fn bit_length(&self) -> usizeReturns the number of bits necessary to represent this value. Note that zero is considered to need 0 bits.
fn add<'a>(&'a mut self, other: &Big32x40) -> &'a mut Big32x40Adds
otherto itself and returns its own mutable reference.fn add_small(&mut self, other: Digit32) -> &mut Big32x40fn sub<'a>(&'a mut self, other: &Big32x40) -> &'a mut Big32x40Subtracts
otherfrom itself and returns its own mutable reference.fn mul_small(&mut self, other: Digit32) -> &mut Big32x40Multiplies itself by a digit-sized
otherand returns its own mutable reference.fn mul_pow2(&mut self, bits: usize) -> &mut Big32x40Multiplies itself by
2^bitsand returns its own mutable reference.fn mul_pow5(&mut self, e: usize) -> &mut Big32x40Multiplies itself by
5^eand returns its own mutable reference.fn mul_digits<'a>(&'a mut self, other: &[Digit32]) -> &'a mut Big32x40Multiplies itself by a number described by
other[0] + other[1] * 2^W + other[2] * 2^(2W) + ...(whereWis the number of bits in the digit type) and returns its own mutable reference.fn div_rem_small(&mut self, other: Digit32) -> (&mut Big32x40, Digit32)Divides itself by a digit-sized
otherand returns its own mutable reference and the remainder.
Trait Implementations
impl Clone for Big32x40
fn clone(&self) -> Self
impl Debug for Big32x40
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Big32x40
impl Ord for Big32x40
fn cmp(&self, other: &Big32x40) -> Ordering
impl PartialEq for Big32x40
fn eq(&self, other: &Big32x40) -> bool
impl PartialOrd for Big32x40
fn partial_cmp(&self, other: &Big32x40) -> Option<Ordering>
impl UseCloned for Big32x40
Auto Trait Implementations
impl Freeze for Big32x40
impl RefUnwindSafe for Big32x40
impl Send for Big32x40
impl Sync for Big32x40
impl Unpin for Big32x40
impl UnsafeUnpin for Big32x40
impl UnwindSafe for Big32x40
Blanket Implementations
impl<T> Any for Big32x40
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Big32x40
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Big32x40
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Big32x40
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Big32x40
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Big32x40
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Big32x40
impl<T, U> Into<U> for Big32x40
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Big32x40
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Big32x40
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>