pub struct F16(/* private fields */);Methods from Deref<Target = f16>§
pub const DIGITS: u32 = 3
pub const EPSILON: f16
pub const INFINITY: f16
pub const MANTISSA_DIGITS: u32 = 11
pub const MAX: f16
pub const MAX_10_EXP: i32 = 4
pub const MAX_EXP: i32 = 16
pub const MIN: f16
pub const MIN_10_EXP: i32 = -4
pub const MIN_EXP: i32 = -13
pub const MIN_POSITIVE: f16
pub const NAN: f16
pub const NEG_INFINITY: f16
pub const RADIX: u32 = 2
pub const MIN_POSITIVE_SUBNORMAL: f16
pub const MAX_SUBNORMAL: f16
pub const ONE: f16
pub const ZERO: f16
pub const NEG_ZERO: f16
pub const NEG_ONE: f16
pub const E: f16
pub const PI: f16
pub const FRAC_1_PI: f16
pub const FRAC_1_SQRT_2: f16
pub const FRAC_2_PI: f16
pub const FRAC_2_SQRT_PI: f16
pub const FRAC_PI_2: f16
pub const FRAC_PI_3: f16
pub const FRAC_PI_4: f16
pub const FRAC_PI_6: f16
pub const FRAC_PI_8: f16
pub const LN_10: f16
pub const LN_2: f16
pub const LOG10_E: f16
pub const LOG10_2: f16
pub const LOG2_E: f16
pub const LOG2_10: f16
pub const SQRT_2: f16
Sourcepub fn total_cmp(&self, other: &f16) -> Ordering
pub fn total_cmp(&self, other: &f16) -> Ordering
Returns the ordering between self and other.
Unlike the standard partial comparison between floating point numbers,
this comparison always produces an ordering in accordance to
the totalOrder predicate as defined in the IEEE 754 (2008 revision)
floating point standard. The values are ordered in the following sequence:
- negative quiet NaN
- negative signaling NaN
- negative infinity
- negative numbers
- negative subnormal numbers
- negative zero
- positive zero
- positive subnormal numbers
- positive numbers
- positive infinity
- positive signaling NaN
- positive quiet NaN.
The ordering established by this function does not always agree with the
PartialOrd and PartialEq implementations of f16. For example,
they consider negative and positive zero equal, while total_cmp
doesn’t.
The interpretation of the signaling NaN bit follows the definition in the IEEE 754 standard, which may not match the interpretation by some of the older, non-conformant (e.g. MIPS) hardware implementations.
§Examples
let mut v: Vec<f16> = vec![];
v.push(f16::ONE);
v.push(f16::INFINITY);
v.push(f16::NEG_INFINITY);
v.push(f16::NAN);
v.push(f16::MAX_SUBNORMAL);
v.push(-f16::MAX_SUBNORMAL);
v.push(f16::ZERO);
v.push(f16::NEG_ZERO);
v.push(f16::NEG_ONE);
v.push(f16::MIN_POSITIVE);
v.sort_by(|a, b| a.total_cmp(&b));
assert!(v
.into_iter()
.zip(
[
f16::NEG_INFINITY,
f16::NEG_ONE,
-f16::MAX_SUBNORMAL,
f16::NEG_ZERO,
f16::ZERO,
f16::MAX_SUBNORMAL,
f16::MIN_POSITIVE,
f16::ONE,
f16::INFINITY,
f16::NAN
]
.iter()
)
.all(|(a, b)| a.to_bits() == b.to_bits()));Trait Implementations§
Source§impl Ord for F16
impl Ord for F16
Source§impl PartialOrd for F16
impl PartialOrd for F16
impl Copy for F16
impl Eq for F16
impl StructuralPartialEq for F16
Auto Trait Implementations§
impl Freeze for F16
impl RefUnwindSafe for F16
impl Send for F16
impl Sync for F16
impl Unpin for F16
impl UnwindSafe for F16
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more