pub struct Denormal<const BASE: usize, B: BigInt<BASE>>(/* private fields */);Expand description
Represents a denormalized number.
A denormalized number may not be in a consistent form, and may behave in unexpected ways while performing mathematical operations. It is typically best practice to normalize a denormalized number before using it in other contexts.
Sometimes, however, maintaining a number in a denormalized state is desirable for one reason or another; for example, performing normalization is a nonzero performance cost; you may save some computation by performing several consecutive operations in a row on a denormalized number before finally normalizing it at the end. Additionally, trailing zeros may be desirable to maintain, for data manipulation purposes.
use big_int::prelude::*;
let a: Tight<10> = 194.into();
let a: DenormalTight<10> = a.sub_inner::<Tight<10>, Tight<10>>(100.into());
assert_eq!(format!("{a}"), "094".to_string());
let a: Tight<10> = a.unwrap();
assert_eq!(format!("{a}"), "94".to_string());Trait Implementations§
Source§impl<const BASE: usize, B: BigInt<BASE>> AddAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> AddAssign for Denormal<BASE, B>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl<const BASE: usize, B: BigInt<BASE>> BigInt<BASE> for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> BigInt<BASE> for Denormal<BASE, B>
type Builder = DenormalBuilder<BASE, <B as BigInt<BASE>>::Builder>
type Denormal = Denormal<BASE, B>
Source§fn get_digit(&self, digit: usize) -> Option<Digit>
fn get_digit(&self, digit: usize) -> Option<Digit>
Get the digit of the big int at position
digit,
or None if the number does not have that many digits. Read moreSource§fn push_back(&mut self, digit: Digit)
fn push_back(&mut self, digit: Digit)
Append a digit to the right side of the int. Equivalent to
(int << 1) + digit Read moreSource§unsafe fn push_front(&mut self, digit: Digit)
unsafe fn push_front(&mut self, digit: Digit)
Append a digit to the left side of the int. Read more
Source§unsafe fn pop_back(&mut self) -> Option<Digit>
unsafe fn pop_back(&mut self) -> Option<Digit>
Pop the rightmost digit from the end of the int, and return it. Read more
Source§unsafe fn pop_front(&mut self) -> Option<Digit>
unsafe fn pop_front(&mut self) -> Option<Digit>
Pop the leftmost digit from the end of the int, and return it. Read more
Source§fn normalized(self) -> Self
fn normalized(self) -> Self
Return a normalized version of the int. A normalized int: Read more
Source§unsafe fn shl_assign_inner(&mut self, amount: usize)
unsafe fn shl_assign_inner(&mut self, amount: usize)
Multiply the int by BASE^amount in place. Read more
Source§fn shl_inner(self, amount: usize) -> Self::Denormal
fn shl_inner(self, amount: usize) -> Self::Denormal
Multiply the int by BASE^amount. Read more
Source§unsafe fn shr_assign_inner(&mut self, amount: usize)
unsafe fn shr_assign_inner(&mut self, amount: usize)
Divide the int by BASE^amount in place. Read more
Source§fn div_rem<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<(OUT, OUT), BigIntError>
fn div_rem<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<(OUT, OUT), BigIntError>
Divide one int by another, returning the quotient & remainder as a pair. Read more
Source§fn exp<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT, BigIntError>
fn exp<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT, BigIntError>
Exponentiate the big int by
rhs. Read moreSource§fn log<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT, BigIntError>
fn log<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT, BigIntError>
Compute the logarithm of the big int with the base
rhs. Read moreSource§fn root<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT, BigIntError>
fn root<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT, BigIntError>
Compute the nth root of the big int, with root
rhs. Read moreSource§fn convert<const TO: usize, OUT: BigInt<TO>>(self) -> OUT
fn convert<const TO: usize, OUT: BigInt<TO>>(self) -> OUT
Convert an int from its own base to another target base,
to another
BigInt type, or both at once. Read moreSource§fn get_back_inner(&self, index: usize) -> Option<Digit>
fn get_back_inner(&self, index: usize) -> Option<Digit>
Default implementation of
big_int::GetBack. Read moreSource§fn default_inner() -> Self
fn default_inner() -> Self
Default implementation of
Default. Read moreSource§fn fmt_inner(&self, f: &mut Formatter<'_>) -> Result
fn fmt_inner(&self, f: &mut Formatter<'_>) -> Result
Default implementation of
Display. Read moreSource§fn partial_cmp_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> Option<Ordering>
fn partial_cmp_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> Option<Ordering>
Default implementation of
PartialOrd. Read moreSource§fn cmp_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> Ordering
fn cmp_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> Ordering
Default implementation of
Ord. Read moreSource§fn eq_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> bool
fn eq_inner<RHS: BigInt<BASE>>(&self, other: &RHS) -> bool
Default implementation of
PartialEq. Read moreSource§fn add_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> OUT::Denormal
fn add_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> OUT::Denormal
Default implementation of
Add. Read moreSource§unsafe fn add_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
unsafe fn add_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
Default implementation of
AddAssign. Read moreSource§fn sub_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> OUT::Denormal
fn sub_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> OUT::Denormal
Default implementation of
Sub. Read moreSource§unsafe fn sub_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
unsafe fn sub_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
Default implementation of
SubAssign. Read moreSource§fn mul_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> OUT::Denormal
fn mul_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> OUT::Denormal
Default implementation of
Mul. Read moreSource§unsafe fn mul_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
unsafe fn mul_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
Default implementation of
MulAssign. Read moreSource§fn div_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> OUT::Denormal
fn div_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> OUT::Denormal
Default implementation of
Div. Read moreSource§unsafe fn div_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
unsafe fn div_assign_inner<RHS: BigInt<BASE>>(&mut self, rhs: RHS)
Default implementation of
DivAssign. Read moreSource§fn from_str_inner(s: &str) -> Result<Self::Denormal, BigIntError>
fn from_str_inner(s: &str) -> Result<Self::Denormal, BigIntError>
Default implementation of
FromStr. Read moreSource§fn from_iter_inner<T: IntoIterator<Item = Digit>>(iter: T) -> Self::Denormal
fn from_iter_inner<T: IntoIterator<Item = Digit>>(iter: T) -> Self::Denormal
Default implementation of
FromIterator. Read moreSource§fn from_u128_inner(value: u128) -> Self::Denormal
fn from_u128_inner(value: u128) -> Self::Denormal
Default implementation of
From<_> for all unsigned primitive int types. Read moreSource§fn from_i128_inner(value: i128) -> Self::Denormal
fn from_i128_inner(value: i128) -> Self::Denormal
Default implementation of
From<_> for all signed primitive int types. Read moreSource§fn into_u128_inner(self) -> u128
fn into_u128_inner(self) -> u128
Default implementation of
Into<_> for all unsigned primitive int types. Read moreSource§fn into_i128_inner(self) -> i128
fn into_i128_inner(self) -> i128
Default implementation of
Into<_> for all signed primitive int types. Read moreSource§fn div_rem_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<(OUT::Denormal, OUT::Denormal), BigIntError>
fn div_rem_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<(OUT::Denormal, OUT::Denormal), BigIntError>
Divide one int by another, returning the quotient & remainder as a pair.
Returns the result as a denormalized pair. Read more
Source§fn exp_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT::Denormal, BigIntError>
fn exp_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT::Denormal, BigIntError>
Exponentiate the big int by
rhs.
Returns the result as a denormalized number. Read moreSource§fn log_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT::Denormal, BigIntError>
fn log_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT::Denormal, BigIntError>
Compute the logarithm of the big int with the base
rhs.
Returns the result as a denormalized number. Read moreSource§fn root_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>(
self,
rhs: RHS,
) -> Result<OUT::Denormal, BigIntError>
fn root_inner<RHS: BigInt<BASE>, OUT: BigInt<BASE>>( self, rhs: RHS, ) -> Result<OUT::Denormal, BigIntError>
Compute the nth root of the big int, with root
rhs.
Returns the result as a denormalized number. Read moreSource§fn iter<'a>(&'a self) -> BigIntIter<'a, BASE, Self> ⓘ
fn iter<'a>(&'a self) -> BigIntIter<'a, BASE, Self> ⓘ
Iterate over the digits of the int. Read more
Source§fn display(&self, alphabet: &str) -> Result<String, BigIntError>
fn display(&self, alphabet: &str) -> Result<String, BigIntError>
Convert a big int to a printable string using the provided alphabet
alphabet.
Display uses this method with the default alphabet STANDARD_ALPHABET. Read moreSource§fn parse(value: &str, alphabet: &str) -> Result<Self::Denormal, ParseError>
fn parse(value: &str, alphabet: &str) -> Result<Self::Denormal, ParseError>
Parse a big int from a
value: &str, referencing the provided alphabet
to determine what characters represent which digits. FromStr uses this method
with the default alphabet STANDARD_ALPHABET. Read moreSource§fn convert_inner<const TO: usize, OUT: BigInt<TO>>(self) -> OUT::Denormal
fn convert_inner<const TO: usize, OUT: BigInt<TO>>(self) -> OUT::Denormal
Convert an int from its own base to another target base,
to another
BigInt type, or both at once. Returns the result as
a denormalized number. Read moreSource§fn cmp_magnitude<RHS: BigInt<BASE>>(&self, rhs: &RHS) -> Ordering
fn cmp_magnitude<RHS: BigInt<BASE>>(&self, rhs: &RHS) -> Ordering
Compare the absolute magnitude of two big ints, ignoring their sign. Read more
const BITS_PER_DIGIT: usize = _
Source§impl<const BASE: usize, B: BigInt<BASE>> DivAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> DivAssign for Denormal<BASE, B>
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreSource§impl<const BASE: usize, B: BigIntBuilder<BASE> + Into<BB::Denormal>, BB: BigInt<BASE>> From<DenormalBuilder<BASE, B>> for Denormal<BASE, BB>
impl<const BASE: usize, B: BigIntBuilder<BASE> + Into<BB::Denormal>, BB: BigInt<BASE>> From<DenormalBuilder<BASE, B>> for Denormal<BASE, BB>
Source§fn from(value: DenormalBuilder<BASE, B>) -> Self
fn from(value: DenormalBuilder<BASE, B>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize> From<LooseBuilder<BASE>> for Denormal<BASE, Loose<BASE>>
impl<const BASE: usize> From<LooseBuilder<BASE>> for Denormal<BASE, Loose<BASE>>
Source§fn from(value: LooseBuilder<BASE>) -> Self
fn from(value: LooseBuilder<BASE>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize> From<LooseBytesBuilder<BASE>> for Denormal<BASE, LooseBytes<BASE>>
impl<const BASE: usize> From<LooseBytesBuilder<BASE>> for Denormal<BASE, LooseBytes<BASE>>
Source§fn from(value: LooseBytesBuilder<BASE>) -> Self
fn from(value: LooseBytesBuilder<BASE>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize> From<LooseShortsBuilder<BASE>> for Denormal<BASE, LooseShorts<BASE>>
impl<const BASE: usize> From<LooseShortsBuilder<BASE>> for Denormal<BASE, LooseShorts<BASE>>
Source§fn from(value: LooseShortsBuilder<BASE>) -> Self
fn from(value: LooseShortsBuilder<BASE>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize> From<LooseWordsBuilder<BASE>> for Denormal<BASE, LooseWords<BASE>>
impl<const BASE: usize> From<LooseWordsBuilder<BASE>> for Denormal<BASE, LooseWords<BASE>>
Source§fn from(value: LooseWordsBuilder<BASE>) -> Self
fn from(value: LooseWordsBuilder<BASE>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize> From<TightBuilder<BASE>> for Denormal<BASE, Tight<BASE>>
impl<const BASE: usize> From<TightBuilder<BASE>> for Denormal<BASE, Tight<BASE>>
Source§fn from(value: TightBuilder<BASE>) -> Self
fn from(value: TightBuilder<BASE>) -> Self
Converts to this type from the input type.
Source§impl<const BASE: usize, B: BigInt<BASE>> MulAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> MulAssign for Denormal<BASE, B>
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<const BASE: usize, B: BigInt<BASE>> Ord for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> Ord for Denormal<BASE, B>
Source§impl<const BASE: usize, B: BigInt<BASE>> PartialOrd for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> PartialOrd for Denormal<BASE, B>
Source§impl<const BASE: usize, B: BigInt<BASE>> ShlAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> ShlAssign for Denormal<BASE, B>
Source§fn shl_assign(&mut self, rhs: Self)
fn shl_assign(&mut self, rhs: Self)
Performs the
<<= operation. Read moreSource§impl<const BASE: usize, B: BigInt<BASE>> ShrAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> ShrAssign for Denormal<BASE, B>
Source§fn shr_assign(&mut self, rhs: Self)
fn shr_assign(&mut self, rhs: Self)
Performs the
>>= operation. Read moreSource§impl<const BASE: usize, B: BigInt<BASE>> SubAssign for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> SubAssign for Denormal<BASE, B>
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreSource§impl<const BASE: usize, B: BigInt<BASE>> UnsafeInto<B> for Denormal<BASE, B>
impl<const BASE: usize, B: BigInt<BASE>> UnsafeInto<B> for Denormal<BASE, B>
unsafe fn unsafe_into(self) -> B
impl<const BASE: usize, B: BigInt<BASE>> Eq for Denormal<BASE, B>
Auto Trait Implementations§
impl<const BASE: usize, B> Freeze for Denormal<BASE, B>where
B: Freeze,
impl<const BASE: usize, B> RefUnwindSafe for Denormal<BASE, B>where
B: RefUnwindSafe,
impl<const BASE: usize, B> Send for Denormal<BASE, B>where
B: Send,
impl<const BASE: usize, B> Sync for Denormal<BASE, B>where
B: Sync,
impl<const BASE: usize, B> Unpin for Denormal<BASE, B>where
B: Unpin,
impl<const BASE: usize, B> UnwindSafe for Denormal<BASE, B>where
B: UnwindSafe,
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
Mutably borrows from an owned value. Read more