Trait malachite_base::num::conversion::traits::IntegerMantissaAndExponent
source · [−]pub trait IntegerMantissaAndExponent<M, E, T = Self>: Sized {
fn integer_mantissa_and_exponent(self) -> (M, E);
fn from_integer_mantissa_and_exponent(
integer_mantissa: M,
integer_exponent: E
) -> Option<T>;
fn integer_mantissa(self) -> M { ... }
fn integer_exponent(self) -> E { ... }
}
Expand description
Converts a number to or from an integer mantissa and exponent.
See here for a definition of integer mantissa and exponent.
The mantissa is an odd integer, and the exponent is an integer, such that $x = 2^em$.
Required Methods
fn integer_mantissa_and_exponent(self) -> (M, E)
fn integer_mantissa_and_exponent(self) -> (M, E)
Extracts the integer mantissa and exponent from a number.
fn from_integer_mantissa_and_exponent(
integer_mantissa: M,
integer_exponent: E
) -> Option<T>
fn from_integer_mantissa_and_exponent(
integer_mantissa: M,
integer_exponent: E
) -> Option<T>
Constructs a number from its integer mantissa and exponent.
Provided Methods
fn integer_mantissa(self) -> M
fn integer_mantissa(self) -> M
Extracts the integer mantissa from a number.
fn integer_exponent(self) -> E
fn integer_exponent(self) -> E
Extracts the integer exponent from a number.
Implementations on Foreign Types
sourceimpl IntegerMantissaAndExponent<u8, u64, u8> for u8
impl IntegerMantissaAndExponent<u8, u64, u8> for u8
sourcefn integer_mantissa_and_exponent(self) -> (u8, u64)
fn integer_mantissa_and_exponent(self) -> (u8, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> u8
fn integer_mantissa(self) -> u8
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u8,
integer_exponent: u64
) -> Option<u8>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u8,
integer_exponent: u64
) -> Option<u8>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u16, u64, u16> for u16
impl IntegerMantissaAndExponent<u16, u64, u16> for u16
sourcefn integer_mantissa_and_exponent(self) -> (u16, u64)
fn integer_mantissa_and_exponent(self) -> (u16, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> u16
fn integer_mantissa(self) -> u16
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u16,
integer_exponent: u64
) -> Option<u16>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u16,
integer_exponent: u64
) -> Option<u16>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u32, u64, u32> for u32
impl IntegerMantissaAndExponent<u32, u64, u32> for u32
sourcefn integer_mantissa_and_exponent(self) -> (u32, u64)
fn integer_mantissa_and_exponent(self) -> (u32, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> u32
fn integer_mantissa(self) -> u32
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u32,
integer_exponent: u64
) -> Option<u32>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u32,
integer_exponent: u64
) -> Option<u32>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u64, u64, u64> for u64
impl IntegerMantissaAndExponent<u64, u64, u64> for u64
sourcefn integer_mantissa_and_exponent(self) -> (u64, u64)
fn integer_mantissa_and_exponent(self) -> (u64, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> u64
fn integer_mantissa(self) -> u64
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: u64
) -> Option<u64>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: u64
) -> Option<u64>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u128, u64, u128> for u128
impl IntegerMantissaAndExponent<u128, u64, u128> for u128
sourcefn integer_mantissa_and_exponent(self) -> (u128, u64)
fn integer_mantissa_and_exponent(self) -> (u128, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> u128
fn integer_mantissa(self) -> u128
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u128,
integer_exponent: u64
) -> Option<u128>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u128,
integer_exponent: u64
) -> Option<u128>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<usize, u64, usize> for usize
impl IntegerMantissaAndExponent<usize, u64, usize> for usize
sourcefn integer_mantissa_and_exponent(self) -> (usize, u64)
fn integer_mantissa_and_exponent(self) -> (usize, u64)
Returns the integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is
from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_mantissa(self) -> usize
fn integer_mantissa(self) -> usize
Returns the integer mantissa.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn integer_exponent(self) -> u64
fn integer_exponent(self) -> u64
Returns the integer exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: usize,
integer_exponent: u64
) -> Option<usize>
fn from_integer_mantissa_and_exponent(
integer_mantissa: usize,
integer_exponent: u64
) -> Option<usize>
Constructs an unsigned primitive integer from its integer mantissa and exponent.
When $x$ is nonzero, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as an integer of the desired
type (this happens if the exponent is too large).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u64, i64, f32> for f32
impl IntegerMantissaAndExponent<u64, i64, f32> for f32
sourcefn integer_mantissa_and_exponent(self) -> (u64, i64)
fn integer_mantissa_and_exponent(self) -> (u64, i64)
Returns the integer mantissa and exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is Self::from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn integer_mantissa(self) -> u64
fn integer_mantissa(self) -> u64
Returns the integer mantissa.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn integer_exponent(self) -> i64
fn integer_exponent(self) -> i64
Returns the integer exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: i64
) -> Option<f32>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: i64
) -> Option<f32>
Constructs a float from its integer mantissa and exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as a float of the desired
type (this happens if the exponent is too large or too small, or if the mantissa’s
precision is too high for the exponent).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.
sourceimpl IntegerMantissaAndExponent<u64, i64, f64> for f64
impl IntegerMantissaAndExponent<u64, i64, f64> for f64
sourcefn integer_mantissa_and_exponent(self) -> (u64, i64)
fn integer_mantissa_and_exponent(self) -> (u64, i64)
Returns the integer mantissa and exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = (\frac{|x|}{2^{e_i}}, e_i), $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
The inverse operation is Self::from_integer_mantissa_and_exponent
.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn integer_mantissa(self) -> u64
fn integer_mantissa(self) -> u64
Returns the integer mantissa.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = \frac{|x|}{2^{e_i}}, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn integer_exponent(self) -> i64
fn integer_exponent(self) -> i64
Returns the integer exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer. $$ f(x) = e_i, $$ where $e_i$ is the unique integer such that $x/2^{e_i}$ is an odd integer.
Worst-case complexity
Constant time and additional memory.
Panics
Panics if self
is zero, infinite, or NaN
.
Examples
See here.
sourcefn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: i64
) -> Option<f64>
fn from_integer_mantissa_and_exponent(
integer_mantissa: u64,
integer_exponent: i64
) -> Option<f64>
Constructs a float from its integer mantissa and exponent.
When $x$ is positive, nonzero, and finite, we can write $x = 2^{e_i}m_i$, where $e_i$ is an integer and $m_i$ is an odd integer.
$$
f(x) = 2^{e_i}m_i,
$$
or None
if the result cannot be exactly represented as a float of the desired
type (this happens if the exponent is too large or too small, or if the mantissa’s
precision is too high for the exponent).
The input does not have to be reduced; that is to say, the mantissa does not have to be odd.
Worst-case complexity
Constant time and additional memory.
Examples
See here.