Struct std::num::bignum::Big32x40 [] [src]

pub struct Big32x40 {
    size: usize,
    base: [u32; 40],
}
Unstable (core_private_bignum)

: internal routines only exposed for testing

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 over/underflows. The caller is responsible to use large enough bignum types.

Fields

size
Unstable (core_private_bignum)

: internal routines only exposed for testing

One 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
Unstable (core_private_bignum)

: internal routines only exposed for testing

Digits. [a, b, c, ...] represents a + b*2^W + c*2^(2W) + ... where W is the number of bits in the digit type.

Methods

impl Big32x40

fn from_small(v: u32) -> Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Makes a bignum from one digit.

fn from_u64(v: u64) -> Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Makes a bignum from u64 value.

fn digits(&self) -> &[u32]

Unstable (core_private_bignum)

: internal routines only exposed for testing

Return the internal digits as a slice [a, b, c, ...] such that the numeric value is a + b * 2^W + c * 2^(2W) + ... where W is the number of bits in the digit type.

fn get_bit(&self, i: usize) -> u8

Unstable (core_private_bignum)

: internal routines only exposed for testing

Return the i-th bit where bit 0 is the least significant one. In other words, the bit with weight 2^i.

fn is_zero(&self) -> bool

Unstable (core_private_bignum)

: internal routines only exposed for testing

Returns true if the bignum is zero.

fn bit_length(&self) -> usize

Unstable (core_private_bignum)

: internal routines only exposed for testing

Returns the number of bits necessary to represent this value. Note that zero is considered to need 0 bits.

fn add(&'a mut self, other: &Big32x40) -> &'a mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Adds other to itself and returns its own mutable reference.

fn add_small(&mut self, other: u32) -> &mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

fn sub(&'a mut self, other: &Big32x40) -> &'a mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Subtracts other from itself and returns its own mutable reference.

fn mul_small(&mut self, other: u32) -> &mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Multiplies itself by a digit-sized other and returns its own mutable reference.

fn mul_pow2(&mut self, bits: usize) -> &mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Multiplies itself by 2^bits and returns its own mutable reference.

fn mul_pow5(&mut self, e: usize) -> &mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Multiplies itself by 5^e and returns its own mutable reference.

fn mul_digits(&'a mut self, other: &[u32]) -> &'a mut Big32x40

Unstable (core_private_bignum)

: internal routines only exposed for testing

Multiplies itself by a number described by other[0] + other[1] * 2^W + other[2] * 2^(2W) + ... (where W is the number of bits in the digit type) and returns its own mutable reference.

fn div_rem_small(&mut self, other: u32) -> (&mut Big32x40, u32)

Unstable (core_private_bignum)

: internal routines only exposed for testing

Divides itself by a digit-sized other and returns its own mutable reference and the remainder.

fn div_rem(&self, d: &Big32x40, q: &mut Big32x40, r: &mut Big32x40)

Unstable (core_private_bignum)

: internal routines only exposed for testing

Divide self by another bignum, overwriting q with the quotient and r with the remainder.

Trait Implementations

impl PartialEq<Big32x40> for Big32x40

fn eq(&self, other: &Big32x40) -> bool

fn ne(&self, other: &Rhs) -> bool

impl Eq for Big32x40

fn assert_receiver_is_total_eq(&self)

impl PartialOrd<Big32x40> for Big32x40

fn partial_cmp(&self, other: &Big32x40) -> Option<Ordering>

fn lt(&self, other: &Rhs) -> bool

fn le(&self, other: &Rhs) -> bool

fn gt(&self, other: &Rhs) -> bool

fn ge(&self, other: &Rhs) -> bool

impl Ord for Big32x40

fn cmp(&self, other: &Big32x40) -> Ordering

impl Clone for Big32x40

fn clone(&self) -> Big32x40

fn clone_from(&mut self, source: &Self)

impl Debug for Big32x40

fn fmt(&self, f: &mut Formatter) -> Result<(), Error>