Struct core::num::bignum::Big32x40
[−]
[src]
pub struct Big32x40 { size: usize, base: [Digit32; 40], }
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 | Unstable ( core_private_bignum ): internal routines only exposed for testing Digits. |
Methods
impl Big32x40
fn from_small(v: Digit32) -> Big32x40
core_private_bignum
): internal routines only exposed for testing
Makes a bignum from one digit.
fn from_u64(v: u64) -> Big32x40
core_private_bignum
): internal routines only exposed for testing
Makes a bignum from u64
value.
fn digits(&self) -> &[Digit32]
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
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
core_private_bignum
): internal routines only exposed for testing
Returns true if the bignum is zero.
fn bit_length(&self) -> usize
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>(&'a mut self, other: &Big32x40) -> &'a mut Big32x40
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: Digit32) -> &mut Big32x40
core_private_bignum
): internal routines only exposed for testing
fn sub<'a>(&'a mut self, other: &Big32x40) -> &'a mut Big32x40
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: Digit32) -> &mut Big32x40
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
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
core_private_bignum
): internal routines only exposed for testing
Multiplies itself by 5^e
and returns its own mutable reference.
fn mul_digits<'a>(&'a mut self, other: &[Digit32]) -> &'a mut Big32x40
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: Digit32) -> (&mut Big32x40, Digit32)
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)
core_private_bignum
): internal routines only exposed for testing
Divide self by another bignum, overwriting q
with the quotient and r
with the
remainder.