pub trait IntegerMantissaAndExponent<M, E, T = Self>: Sized {
    // Required methods
    fn integer_mantissa_and_exponent(self) -> (M, E);
    fn from_integer_mantissa_and_exponent(
        integer_mantissa: M,
        integer_exponent: E
    ) -> Option<T>;

    // Provided methods
    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§

source

fn integer_mantissa_and_exponent(self) -> (M, E)

Extracts the integer mantissa and exponent from a number.

source

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§

source

fn integer_mantissa(self) -> M

Extracts the integer mantissa from a number.

source

fn integer_exponent(self) -> E

Extracts the integer exponent from a number.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl IntegerMantissaAndExponent<u8, u64> for u8

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u16, u64> for u16

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u32, u64> for u32

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u64, i64> for f32

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u64, i64> for f64

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u64, u64> for u64

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<u128, u64> for u128

source§

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.

source§

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.

source§

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.

source§

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.

source§

impl IntegerMantissaAndExponent<usize, u64> for usize

source§

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.

source§

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.

source§

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.

source§

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.

Implementors§