Struct Big64x20
pub struct Big64x20 { pub(in ::num::imp::bignum) size: usize, pub(in ::num::imp::bignum) base: [Digit64; 20] }
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: [Digit64; 20]Digits.
[a, b, c, ...]representsa + b*2^W + c*2^(2W) + ...whereWis the number of bits in the digit type.
Implementations
impl Big64x20
fn from_small(v: Digit64) -> Big64x20Makes a bignum from one digit.
fn from_u64(v: u64) -> Big64x20Makes a bignum from
u64value.fn digits(&self) -> &[Digit64]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: &Big64x20) -> &'a mut Big64x20Adds
otherto itself and returns its own mutable reference.fn add_small(&mut self, other: Digit64) -> &mut Big64x20fn sub<'a>(&'a mut self, other: &Big64x20) -> &'a mut Big64x20Subtracts
otherfrom itself and returns its own mutable reference.fn mul_small(&mut self, other: Digit64) -> &mut Big64x20Multiplies itself by a digit-sized
otherand returns its own mutable reference.fn mul_pow2(&mut self, bits: usize) -> &mut Big64x20Multiplies itself by
2^bitsand returns its own mutable reference.fn mul_pow5(&mut self, e: usize) -> &mut Big64x20Multiplies itself by
5^eand returns its own mutable reference.fn mul_digits<'a>(&'a mut self, other: &[Digit64]) -> &'a mut Big64x20Multiplies 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: Digit64) -> (&mut Big64x20, Digit64)Divides itself by a digit-sized
otherand returns its own mutable reference and the remainder.
Trait Implementations
impl Clone for Big64x20
fn clone(&self) -> Self
impl Debug for Big64x20
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Big64x20
impl Ord for Big64x20
fn cmp(&self, other: &Big64x20) -> Ordering
impl PartialEq for Big64x20
fn eq(&self, other: &Big64x20) -> bool
impl PartialOrd for Big64x20
fn partial_cmp(&self, other: &Big64x20) -> Option<Ordering>
impl UseCloned for Big64x20
Auto Trait Implementations
impl Freeze for Big64x20
impl RefUnwindSafe for Big64x20
impl Send for Big64x20
impl Sync for Big64x20
impl Unpin for Big64x20
impl UnsafeUnpin for Big64x20
impl UnwindSafe for Big64x20
Blanket Implementations
impl<T> Any for Big64x20
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Big64x20
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Big64x20
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Big64x20
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Big64x20
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for Big64x20
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for Big64x20
impl<T, U> Into<U> for Big64x20
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 Big64x20
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Big64x20
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>