pub struct Big8x3 {
size: usize,
base: [u8; 3],
}
core_private_bignum
)Expand description
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: usize
core_private_bignum
)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: [u8; 3]
core_private_bignum
)Digits. [a, b, c, ...]
represents a + b*2^W + c*2^(2W) + ...
where W
is the number of bits in the digit type.
Implementationsยง
Sourceยงimpl Big8x3
impl Big8x3
Sourcepub fn from_small(v: u8) -> Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn from_small(v: u8) -> Big8x3
core_private_bignum
)Makes a bignum from one digit.
Sourcepub fn from_u64(v: u64) -> Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn from_u64(v: u64) -> Big8x3
core_private_bignum
)Makes a bignum from u64
value.
Sourcepub fn digits(&self) -> &[u8]
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn digits(&self) -> &[u8]
core_private_bignum
)Returns 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.
Sourcepub fn get_bit(&self, i: usize) -> u8
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn get_bit(&self, i: usize) -> u8
core_private_bignum
)Returns the i
-th bit where bit 0 is the least significant one.
In other words, the bit with weight 2^i
.
Sourcepub fn is_zero(&self) -> bool
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn is_zero(&self) -> bool
core_private_bignum
)Returns true
if the bignum is zero.
Sourcepub fn bit_length(&self) -> usize
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn bit_length(&self) -> usize
core_private_bignum
)Returns the number of bits necessary to represent this value. Note that zero is considered to need 0 bits.
Sourcepub fn add<'a>(&'a mut self, other: &Big8x3) -> &'a mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn add<'a>(&'a mut self, other: &Big8x3) -> &'a mut Big8x3
core_private_bignum
)Adds other
to itself and returns its own mutable reference.
pub fn add_small(&mut self, other: u8) -> &mut Big8x3
core_private_bignum
)Sourcepub fn sub<'a>(&'a mut self, other: &Big8x3) -> &'a mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn sub<'a>(&'a mut self, other: &Big8x3) -> &'a mut Big8x3
core_private_bignum
)Subtracts other
from itself and returns its own mutable reference.
Sourcepub fn mul_small(&mut self, other: u8) -> &mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn mul_small(&mut self, other: u8) -> &mut Big8x3
core_private_bignum
)Multiplies itself by a digit-sized other
and returns its own
mutable reference.
Sourcepub fn mul_pow2(&mut self, bits: usize) -> &mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn mul_pow2(&mut self, bits: usize) -> &mut Big8x3
core_private_bignum
)Multiplies itself by 2^bits
and returns its own mutable reference.
Sourcepub fn mul_pow5(&mut self, e: usize) -> &mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn mul_pow5(&mut self, e: usize) -> &mut Big8x3
core_private_bignum
)Multiplies itself by 5^e
and returns its own mutable reference.
Sourcepub fn mul_digits<'a>(&'a mut self, other: &[u8]) -> &'a mut Big8x3
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn mul_digits<'a>(&'a mut self, other: &[u8]) -> &'a mut Big8x3
core_private_bignum
)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.
Sourcepub fn div_rem_small(&mut self, other: u8) -> (&mut Big8x3, u8)
๐ฌThis is a nightly-only experimental API. (core_private_bignum
)
pub fn div_rem_small(&mut self, other: u8) -> (&mut Big8x3, u8)
core_private_bignum
)Divides itself by a digit-sized other
and returns its own
mutable reference and the remainder.
Trait Implementationsยง
Sourceยงimpl Ord for Big8x3
impl Ord for Big8x3
1.21.0 ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงimpl PartialOrd for Big8x3
impl PartialOrd for Big8x3
Sourceยง#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)self == other
, returns ControlFlow::Continue(())
.
Otherwise, returns ControlFlow::Break(self < other)
. Read moreSourceยง#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for <=
instead of <
.Sourceยง#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >
instead of <
.Sourceยง#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >=
instead of <
.impl UseCloned for Big8x3
Auto Trait Implementationsยง
impl Freeze for Big8x3
impl RefUnwindSafe for Big8x3
impl Send for Big8x3
impl Sync for Big8x3
impl Unpin for Big8x3
impl UnsafeUnpin for Big8x3
impl UnwindSafe for Big8x3
Blanket Implementationsยง
Sourceยงimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Sourceยงfn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Sourceยงimpl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Sourceยงimpl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Sourceยง#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
sized_type_properties
)Sourceยง#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
sized_type_properties
)Sourceยง#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
sized_type_properties
)[Self]
. Read more