pub struct F16(pub u16);Expand description
IEEE 754 binary16 half-precision float.
Stored as u16. All arithmetic is performed by promoting to f64, computing, then narrowing back. This ensures deterministic behavior regardless of platform, since the f64 path is well-defined.
Tuple Fields§
§0: u16Implementations§
Source§impl F16
impl F16
Sourcepub const NEG_INFINITY: F16
pub const NEG_INFINITY: F16
Negative infinity.
Sourcepub const MIN_POSITIVE_SUBNORMAL: F16
pub const MIN_POSITIVE_SUBNORMAL: F16
Minimum positive subnormal.
Sourcepub fn to_f64(self) -> f64
pub fn to_f64(self) -> f64
Convert f16 to f64.
Handles normals, subnormals, zeros, infinities, and NaNs.
Sourcepub fn from_f64(value: f64) -> Self
pub fn from_f64(value: f64) -> Self
Convert f64 to f16 (round-to-nearest-even).
Handles overflow to infinity, underflow to zero, and subnormals.
Sourcepub fn is_infinite(self) -> bool
pub fn is_infinite(self) -> bool
Check if this is infinite.
Sourcepub fn is_subnormal(self) -> bool
pub fn is_subnormal(self) -> bool
Check if this is subnormal (exponent == 0, mantissa != 0).
Sourcepub fn add(self, rhs: Self) -> Self
pub fn add(self, rhs: Self) -> Self
Add two f16 values. Promotes both to f64, adds, then narrows back.
Sourcepub fn sub(self, rhs: Self) -> Self
pub fn sub(self, rhs: Self) -> Self
Subtract rhs from self. Promotes both to f64, subtracts, then narrows back.
Sourcepub fn mul(self, rhs: Self) -> Self
pub fn mul(self, rhs: Self) -> Self
Multiply two f16 values. Promotes both to f64, multiplies, then narrows back.
Trait Implementations§
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 UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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