pub struct BigInt<const PARTS: usize> { /* private fields */ }Expand description
This is a fixed-size big int implementation that’s used to represent the significand part of the floating point number.
Implementations§
source§impl<const PARTS: usize> BigInt<PARTS>
impl<const PARTS: usize> BigInt<PARTS>
sourcepub fn cast<const P: usize>(&self) -> BigInt<P>
pub fn cast<const P: usize>(&self) -> BigInt<P>
Convert this instance to a smaller number. Notice that this may truncate the number.
sourcepub fn get_loss_kind_for_bit(&self, bit: usize) -> LossFraction
pub fn get_loss_kind_for_bit(&self, bit: usize) -> LossFraction
Returns the fractional part that’s lost during truncation at bit.
sourcepub fn msb_index(&self) -> usize
pub fn msb_index(&self) -> usize
Returns the index of the most significant bit (the highest ‘1’), using 1-based counting (the first bit is 1, and zero means no bits are set).
sourcepub fn trailing_zeros(&self) -> usize
pub fn trailing_zeros(&self) -> usize
Returns the index of the first ‘1’ in the number. The number must not be a zero.
pub fn from_parts(parts: &[u64; PARTS]) -> Self
sourcepub fn inplace_add(&mut self, rhs: &Self) -> bool
pub fn inplace_add(&mut self, rhs: &Self) -> bool
Add rhs to self, and return true if the operation overflowed.
sourcepub fn inplace_sub(&mut self, rhs: &Self) -> bool
pub fn inplace_sub(&mut self, rhs: &Self) -> bool
Add rhs to self, and return true if the operation overflowed (borrow).
sourcepub fn inplace_mul<const P2: usize>(&mut self, rhs: Self) -> bool
pub fn inplace_mul<const P2: usize>(&mut self, rhs: Self) -> bool
Multiply rhs to self, and return true if the operation overflowed.
The generic parameter P2 is here to work around a limitation in the
rust generic system. P2 needs to be greater or equal to PARTS*2.
sourcepub fn inplace_div(&mut self, divisor: Self) -> Self
pub fn inplace_div(&mut self, divisor: Self) -> Self
Divide self by divisor, and return the reminder.
sourcepub fn shift_left(&mut self, bits: usize)
pub fn shift_left(&mut self, bits: usize)
Shift the bits in the numbers bits to the left.
sourcepub fn shift_right(&mut self, bits: usize)
pub fn shift_right(&mut self, bits: usize)
Shift the bits in the numbers bits to the right.
pub fn dump(&self)
Trait Implementations§
source§impl<const PARTS: usize> Ord for BigInt<PARTS>
impl<const PARTS: usize> Ord for BigInt<PARTS>
source§impl<const PARTS: usize> PartialEq<BigInt<PARTS>> for BigInt<PARTS>
impl<const PARTS: usize> PartialEq<BigInt<PARTS>> for BigInt<PARTS>
source§impl<const PARTS: usize> PartialOrd<BigInt<PARTS>> for BigInt<PARTS>
impl<const PARTS: usize> PartialOrd<BigInt<PARTS>> for BigInt<PARTS>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more