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
impl RFloat
sourcepub fn canonicalize(&self) -> Self
pub fn canonicalize(&self) -> Self
Canonicalizes this number. All zeros are mapped to +0.0.
sourcepub fn get_bit(&self, n: isize) -> Option<bool>
pub fn get_bit(&self, n: isize) -> Option<bool>
Returns the n
th absolute binary digit.
Only well-defined for finite, non-zero numbers.
sourcepub fn from_number<N: Real>(val: &N) -> Self
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 PartialEq for RFloat
impl PartialEq for RFloat
source§impl PartialOrd for RFloat
impl PartialOrd for RFloat
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
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 moresource§impl Real for RFloat
impl Real for RFloat
source§fn sign(&self) -> Option<bool>
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>
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>
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>
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>
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>
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>
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
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
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
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_negative(&self) -> Option<bool>
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
fn is_numerical(&self) -> bool
Returns
true
if this number represents a numerical value:
either a finite number, interval, or some limiting value.Auto Trait Implementations§
impl RefUnwindSafe for RFloat
impl Send for RFloat
impl Sync for RFloat
impl Unpin for RFloat
impl UnwindSafe for RFloat
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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.