[−]Struct nannou::vk::half::f16
The 16-bit floating point type.
Methods
impl f16
pub fn from_bits(bits: u16) -> f16
Constructs a 16-bit floating point value from the raw bits.
pub fn from_f32(value: f32) -> f16
Constructs a 16-bit floating point value from a 32-bit floating point value.
If the 32-bit value is to large to fit in 16-bits, +/- infinity will result. NaN values are preserved. 32-bit subnormal values are too tiny to be represented in 16-bits and result in +/- 0. Exponents that underflow the minimum 16-bit exponent will result in 16-bit subnormals or +/- 0. All other values are truncated and rounded to the nearest representable 16-bit value.
pub fn from_f64(value: f64) -> f16
Constructs a 16-bit floating point value from a 64-bit floating point value.
If the 64-bit value is to large to fit in 16-bits, +/- infinity will result. NaN values are preserved. 64-bit subnormal values are too tiny to be represented in 16-bits and result in +/- 0. Exponents that underflow the minimum 16-bit exponent will result in 16-bit subnormals or +/- 0. All other values are truncated and rounded to the nearest representable 16-bit value.
pub fn to_bits(self) -> u16
Converts an f16
into the underlying bit representation.
pub fn as_bits(self) -> u16
renamed to to_bits
Converts an f16
into the underlying bit representation.
pub fn to_f32(self) -> f32
Converts an f16
value in a f32
value.
This conversion is lossless as all 16-bit floating point values can be represented exactly in 32-bit floating point.
pub fn to_f64(self) -> f64
Converts an f16
value in a f64
value.
This conversion is lossless as all 16-bit floating point values can be represented exactly in 64-bit floating point.
pub fn is_nan(self) -> bool
Returns true
if this value is NaN
and false
otherwise.
Examples
use half::f16; let nan = half::consts::NAN; let f = f16::from_f32(7.0_f32); assert!(nan.is_nan()); assert!(!f.is_nan());
pub fn is_infinite(self) -> bool
Returns true
if this value is positive infinity or negative infinity and false
otherwise.
Examples
use half::f16; let f = f16::from_f32(7.0f32); let inf = half::consts::INFINITY; let neg_inf = half::consts::NEG_INFINITY; let nan = half::consts::NAN; assert!(!f.is_infinite()); assert!(!nan.is_infinite()); assert!(inf.is_infinite()); assert!(neg_inf.is_infinite());
pub fn is_finite(self) -> bool
Returns true
if this number is neither infinite nor NaN
.
Examples
use half::f16; let f = f16::from_f32(7.0f32); let inf = half::consts::INFINITY; let neg_inf = half::consts::NEG_INFINITY; let nan = half::consts::NAN; assert!(f.is_finite()); assert!(!nan.is_finite()); assert!(!inf.is_finite()); assert!(!neg_inf.is_finite());
pub fn is_normal(self) -> bool
Returns true
if the number is neither zero, infinite, subnormal, or NaN
.
Examples
use half::f16; let min = half::consts::MIN_POSITIVE; let max = half::consts::MAX; let lower_than_min = f16::from_f32(1.0e-10_f32); let zero = f16::from_f32(0.0_f32); assert!(min.is_normal()); assert!(max.is_normal()); assert!(!zero.is_normal()); assert!(!half::consts::NAN.is_normal()); assert!(!half::consts::INFINITY.is_normal()); // Values between `0` and `min` are Subnormal. assert!(!lower_than_min.is_normal());
pub fn classify(self) -> FpCategory
Returns the floating point category of the number.
If only one property is going to be tested, it is generally faster to use the specific predicate instead.
Examples
use std::num::FpCategory; use half::f16; let num = f16::from_f32(12.4_f32); let inf = half::consts::INFINITY; assert_eq!(num.classify(), FpCategory::Normal); assert_eq!(inf.classify(), FpCategory::Infinite);
pub fn signum(self) -> f16
Returns a number that represents the sign of self
.
1.0
if the number is positive,+0.0
orINFINITY
-1.0
if the number is negative,-0.0
orNEG_INFINITY
NAN
if the number isNAN
Examples
use half::f16; let f = f16::from_f32(3.5_f32); assert_eq!(f.signum(), f16::from_f32(1.0)); assert_eq!(half::consts::NEG_INFINITY.signum(), f16::from_f32(-1.0)); assert!(half::consts::NAN.signum().is_nan());
pub fn is_sign_positive(self) -> bool
Returns true
if and only if self
has a positive sign, including +0.0
, NaNs
with
positive sign bit and positive infinity.
Examples
use half::f16; let nan = half::consts::NAN; let f = f16::from_f32(7.0_f32); let g = f16::from_f32(-7.0_f32); assert!(f.is_sign_positive()); assert!(!g.is_sign_positive()); // `NaN` can be either positive or negative assert!(nan.is_sign_positive() != nan.is_sign_negative());
pub fn is_sign_negative(self) -> bool
Returns true
if and only if self
has a negative sign, including -0.0
, NaNs
with
negative sign bit and negative infinity.
Examples
use half::f16; let nan = half::consts::NAN; let f = f16::from_f32(7.0f32); let g = f16::from_f32(-7.0f32); assert!(!f.is_sign_negative()); assert!(g.is_sign_negative()); // `NaN` can be either positive or negative assert!(nan.is_sign_positive() != nan.is_sign_negative());
Trait Implementations
impl AcceptsPixels<f16> for R16G16B16A16Sfloat
[src]
fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>
[src]
fn rate(&self) -> u32
[src]
impl AcceptsPixels<f16> for R16Sfloat
[src]
fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>
[src]
fn rate(&self) -> u32
[src]
The number of T
s which make up a single pixel. Read more
impl AcceptsPixels<f16> for R16G16B16Sfloat
[src]
fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>
[src]
fn rate(&self) -> u32
[src]
impl AcceptsPixels<f16> for R16G16Sfloat
[src]
fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>
[src]
fn rate(&self) -> u32
[src]
impl AcceptsPixels<f16> for Format
[src]
fn ensure_accepts(&self) -> Result<(), IncompatiblePixelsType>
[src]
fn rate(&self) -> u32
[src]
impl From<i8> for f16
impl From<u8> for f16
impl Display for f16
impl Default for f16
impl PartialEq<f16> for f16
fn eq(&self, other: &f16) -> bool
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Clone for f16
fn clone(&self) -> f16
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl FromStr for f16
type Err = ParseFloatError
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<f16, ParseFloatError>
impl Debug for f16
impl Copy for f16
impl LowerExp for f16
impl UpperExp for f16
impl PartialOrd<f16> for f16
Auto Trait Implementations
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Style for T where
T: Any + Debug + PartialEq<T>,
[src]
T: Any + Debug + PartialEq<T>,
impl<T> Content for T
[src]
fn ref_from_ptr(ptr: *mut c_void, size: usize) -> Option<*mut T>
[src]
fn is_size_suitable(size: usize) -> bool
[src]
fn indiv_size() -> usize
[src]
impl<T> SafeBorrow<T> for T
[src]
impl<T> Erased for T
impl<S> FromSample<S> for S
[src]
fn from_sample_(s: S) -> S
[src]
impl<T, U> ToSample<U> for T where
U: FromSample<T>,
[src]
U: FromSample<T>,
fn to_sample_(self) -> U
[src]
impl<S, T> Duplex<S> for T where
T: FromSample<S> + ToSample<S>,
[src]
T: FromSample<S> + ToSample<S>,
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
T: Parameter<Self>,
T: Parameter<Self>,
Sets value
as a parameter of self
.