pub struct Bf16(/* private fields */);Methods from Deref<Target = bf16>§
pub const DIGITS: u32 = 2
pub const EPSILON: bf16
pub const INFINITY: bf16
pub const MANTISSA_DIGITS: u32 = 8
pub const MAX: bf16
pub const MAX_10_EXP: i32 = 38
pub const MAX_EXP: i32 = 128
pub const MIN: bf16
pub const MIN_10_EXP: i32 = -37
pub const MIN_EXP: i32 = -125
pub const MIN_POSITIVE: bf16
pub const NAN: bf16
pub const NEG_INFINITY: bf16
pub const RADIX: u32 = 2
pub const MIN_POSITIVE_SUBNORMAL: bf16
pub const MAX_SUBNORMAL: bf16
pub const ONE: bf16
pub const ZERO: bf16
pub const NEG_ZERO: bf16
pub const NEG_ONE: bf16
pub const E: bf16
pub const PI: bf16
pub const FRAC_1_PI: bf16
pub const FRAC_1_SQRT_2: bf16
pub const FRAC_2_PI: bf16
pub const FRAC_2_SQRT_PI: bf16
pub const FRAC_PI_2: bf16
pub const FRAC_PI_3: bf16
pub const FRAC_PI_4: bf16
pub const FRAC_PI_6: bf16
pub const FRAC_PI_8: bf16
pub const LN_10: bf16
pub const LN_2: bf16
pub const LOG10_E: bf16
pub const LOG10_2: bf16
pub const LOG2_E: bf16
pub const LOG2_10: bf16
pub const SQRT_2: bf16
Sourcepub fn total_cmp(&self, other: &bf16) -> Ordering
pub fn total_cmp(&self, other: &bf16) -> 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 bf16. 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<bf16> = vec![];
v.push(bf16::ONE);
v.push(bf16::INFINITY);
v.push(bf16::NEG_INFINITY);
v.push(bf16::NAN);
v.push(bf16::MAX_SUBNORMAL);
v.push(-bf16::MAX_SUBNORMAL);
v.push(bf16::ZERO);
v.push(bf16::NEG_ZERO);
v.push(bf16::NEG_ONE);
v.push(bf16::MIN_POSITIVE);
v.sort_by(|a, b| a.total_cmp(&b));
assert!(v
.into_iter()
.zip(
[
bf16::NEG_INFINITY,
bf16::NEG_ONE,
-bf16::MAX_SUBNORMAL,
bf16::NEG_ZERO,
bf16::ZERO,
bf16::MAX_SUBNORMAL,
bf16::MIN_POSITIVE,
bf16::ONE,
bf16::INFINITY,
bf16::NAN
]
.iter()
)
.all(|(a, b)| a.to_bits() == b.to_bits()));Trait Implementations§
Source§impl Ord for Bf16
impl Ord for Bf16
Source§impl PartialOrd for Bf16
impl PartialOrd for Bf16
impl Copy for Bf16
impl Eq for Bf16
impl StructuralPartialEq for Bf16
Auto Trait Implementations§
impl Freeze for Bf16
impl RefUnwindSafe for Bf16
impl Send for Bf16
impl Sync for Bf16
impl Unpin for Bf16
impl UnwindSafe for Bf16
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