Struct std::num::bignum::tests::Big8x3
[−]
[src]
pub struct Big8x3 { size: usize, base: [u8; 3], }
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 Big8x3
fn from_small(v: u8) -> Big8x3
core_private_bignum
): internal routines only exposed for testing
Makes a bignum from one digit.
fn from_u64(v: u64) -> Big8x3
core_private_bignum
): internal routines only exposed for testing
Makes a bignum from u64
value.
fn digits(&self) -> &[u8]
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 mut self, other: &Big8x3) -> &'a mut Big8x3
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: u8) -> &mut Big8x3
core_private_bignum
): internal routines only exposed for testing
fn sub(&'a mut self, other: &Big8x3) -> &'a mut Big8x3
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: u8) -> &mut Big8x3
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 Big8x3
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 Big8x3
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: &[u8]) -> &'a mut Big8x3
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: u8) -> (&mut Big8x3, u8)
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: &Big8x3, q: &mut Big8x3, r: &mut Big8x3)
core_private_bignum
): internal routines only exposed for testing
Divide self by another bignum, overwriting q
with the quotient and r
with the
remainder.