pub trait FloatBits {
type Item: Copy + PartialEq + BitAnd<Output = Self::Item> + Add<Output = Self::Item> + Sub<Output = Self::Item>;
const TINY_BITS: Self::Item;
const NEG_TINY_BITS: Self::Item;
const CLEAR_SIGN_MASK: Self::Item;
const ONE: Self::Item;
const ZERO: Self::Item;
// Required methods
fn to_bits(self) -> Self::Item;
fn from_bits(bits: Self::Item) -> Self;
fn float_is_nan(self) -> bool;
fn infinity() -> Self;
fn neg_infinity() -> Self;
}
Expand description
A trait to manipulate floating-point types with bitwise operations. Provides functions to convert a floating-point value to/from its bitwise representation as well as utility methods to handle special values.
Required Associated Constants§
Sourceconst TINY_BITS: Self::Item
const TINY_BITS: Self::Item
The smallest positive floating-point value representable by this type.
Sourceconst NEG_TINY_BITS: Self::Item
const NEG_TINY_BITS: Self::Item
The smallest (in magnitude) negative floating-point value representable by this type.
Sourceconst CLEAR_SIGN_MASK: Self::Item
const CLEAR_SIGN_MASK: Self::Item
A mask to clear the sign bit of the floating-point value’s bitwise representation.
Required Associated Types§
Required Methods§
Sourcefn to_bits(self) -> Self::Item
fn to_bits(self) -> Self::Item
Converts the floating-point value to its bitwise representation.
Sourcefn from_bits(bits: Self::Item) -> Self
fn from_bits(bits: Self::Item) -> Self
Converts the bitwise representation to the corresponding floating-point value.
Sourcefn float_is_nan(self) -> bool
fn float_is_nan(self) -> bool
Returns true if the floating-point value is NaN (not a number).
Sourcefn neg_infinity() -> Self
fn neg_infinity() -> Self
Returns the negative infinity value for this floating-point type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.