Enum mpmfnum::rfloat::RFloat

source ·
pub enum RFloat {
    Real(bool, isize, Integer),
    PosInfinity,
    NegInfinity,
    Nan,
}
Expand description

An arbitrary-precision, floating-point numbers with unbounded exponent.

The associated RoundingContext implementation is RFloatContext. See RFloatContext for more details on numerical properties of the RFloat type.

All operations canonicalize -0 to +0 (no sign bit).

Variants§

§

Real(bool, isize, Integer)

A finite (real) number specified by the canonical triple of sign, exponent, significand.

§

PosInfinity

A positive infinity.

§

NegInfinity

A negative infinity.

§

Nan

Not a real number; either an undefined or infinte result.

Implementations§

source§

impl RFloat

source

pub fn zero() -> Self

Constructs the canonical zero for this format.

source

pub fn one() -> Self

Constructs the canonical +1 for this format.

source

pub fn is_nan(&self) -> bool

Returns true if the value is not-a-number.

source

pub fn canonicalize(&self) -> Self

Canonicalizes this number. All zeros are mapped to +0.0.

source

pub fn get_bit(&self, n: isize) -> Option<bool>

Returns the nth absolute binary digit. Only well-defined for finite, non-zero numbers.

source

pub fn from_number<N: Real>(val: &N) -> Self

Constructs a [ RFloat] value from a [Real]. This is the default conversion function from any implementation of the [Real`] trait.

Trait Implementations§

source§

impl Add for RFloat

§

type Output = RFloat

The resulting type after applying the + operator.
source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
source§

impl Clone for RFloat

source§

fn clone(&self) -> RFloat

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for RFloat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Fixed> for RFloat

source§

fn from(val: Fixed) -> Self

Converts to this type from the input type.
source§

impl From<Float> for RFloat

source§

fn from(value: Float) -> Self

Converts to this type from the input type.
source§

impl From<Float> for RFloat

source§

fn from(val: Float) -> Self

Converts to this type from the input type.
source§

impl From<IEEE754> for RFloat

source§

fn from(val: IEEE754) -> Self

Converts to this type from the input type.
source§

impl From<Posit> for RFloat

source§

fn from(value: Posit) -> Self

Converts to this type from the input type.
source§

impl From<RFloat> for Float

source§

fn from(val: RFloat) -> Self

Converts to this type from the input type.
source§

impl Mul for RFloat

§

type Output = RFloat

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
source§

impl Neg for RFloat

§

type Output = RFloat

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl PartialEq for RFloat

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for RFloat

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Real for RFloat

source§

fn radix() -> usize

Radix of a number. It must be strictly positive.
source§

fn sign(&self) -> Option<bool>

The sign bit. This is not always well-defined, so the result is an Option. This is distinct from is_negative (e.g. -0.0 is not negative).
source§

fn exp(&self) -> Option<isize>

The exponent of this number when viewed as (-1)^s * c * b^exp where c is an integer integer. Only well-defined for finite, non-zero numbers.
source§

fn e(&self) -> Option<isize>

The exponent of this number when viewed as (-1)^s * f * b^e where f is a fraction between 1 and 2. This is the preferred IEEE 754 interpretation of an exponent. Only well-defined for finite, non-zero numbers.
source§

fn n(&self) -> Option<isize>

The “absolute digit”, the place below the least significant digit of the mantissa. Always equal to self.exp() - 1. For integer formats, this is just -1. Only well-defined for finite, non-zero numbers.
source§

fn c(&self) -> Option<Integer>

The _unsigned“ integer significand of this number when viewed as (-1)^s * c * b^exp. Only well-defined for finite, non-zero numbers. Only well-defined for finite, non-zero numbers.
source§

fn m(&self) -> Option<Integer>

The signed integer significand of this number when viewed as (-1)^s * c * b^exp. Only well-defined for finite, non-zero numbers. Only well-defined for finite, non-zero numbers.
source§

fn prec(&self) -> Option<usize>

Precision of the significand. This is just floor(logb(c)) where b is the radix and c is the integer significand. Only well-defined for finite, non-zero numbers.
source§

fn is_nar(&self) -> bool

Returns true if this number is not a real number. Example: NaN or +/-Inf from the IEEE 754 standard.
source§

fn is_finite(&self) -> bool

Returns true if this number is finite. For values that do not encode numbers, intervals, or even limiting behavior, the result is false.
source§

fn is_infinite(&self) -> bool

Returns true if this number if infinite. For values that do not encode numbers, intervals, or even limiting behavior, the result is false.
source§

fn is_zero(&self) -> bool

Returns true if this number is zero.
source§

fn is_negative(&self) -> Option<bool>

Returns true if this number is negative. This is not always well-defined, so the result is an Option. This is not necessarily the same as the sign bit (the IEEE 754 standard differentiates between -0.0 and +0.0).
source§

fn is_numerical(&self) -> bool

Returns true if this number represents a numerical value: either a finite number, interval, or some limiting value.
source§

fn split(&self, n: isize) -> (RFloat, RFloat)

Splits this value at the nth binary digit, returning two RFloat values. Read more
source§

impl Sub for RFloat

§

type Output = RFloat

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.