[−][src]Trait softfloat_wrapper::Float
arbitrary floting-point type
Examples
Float
can be used for generic functions.
use softfloat_wrapper::{Float, RoundingMode, F16, F32}; fn rsqrt<T: Float>(x: T) -> T { let ret = x.sqrt(RoundingMode::TiesToEven); let one = T::from_u8(1, RoundingMode::TiesToEven); one.div(ret, RoundingMode::TiesToEven) } let a = F16::from_bits(0x1234); let a = rsqrt(a); let a = F32::from_bits(0x12345678); let a = rsqrt(a);
Associated Types
Loading content...Associated Constants
const EXPONENT_BIT: Self::Payload
const FRACTION_BIT: Self::Payload
const SIGN_POS: usize
const EXPONENT_POS: usize
Required methods
fn set_payload(&mut self, x: Self::Payload)
fn from_bits(v: Self::Payload) -> Self
fn bits(&self) -> Self::Payload
fn add<T: Borrow<Self>>(&self, x: T, rnd: RoundingMode) -> Self
fn sub<T: Borrow<Self>>(&self, x: T, rnd: RoundingMode) -> Self
fn mul<T: Borrow<Self>>(&self, x: T, rnd: RoundingMode) -> Self
fn fused_mul_add<T: Borrow<Self>>(&self, x: T, y: T, rnd: RoundingMode) -> Self
fn div<T: Borrow<Self>>(&self, x: T, rnd: RoundingMode) -> Self
fn rem<T: Borrow<Self>>(&self, x: T, rnd: RoundingMode) -> Self
fn sqrt(&self, rnd: RoundingMode) -> Self
fn eq<T: Borrow<Self>>(&self, x: T) -> bool
fn lt<T: Borrow<Self>>(&self, x: T) -> bool
fn le<T: Borrow<Self>>(&self, x: T) -> bool
fn lt_quiet<T: Borrow<Self>>(&self, x: T) -> bool
fn le_quiet<T: Borrow<Self>>(&self, x: T) -> bool
fn from_u32(x: u32, rnd: RoundingMode) -> Self
fn from_u64(x: u64, rnd: RoundingMode) -> Self
fn from_i32(x: i32, rnd: RoundingMode) -> Self
fn from_i64(x: i64, rnd: RoundingMode) -> Self
fn to_u32(&self, rnd: RoundingMode) -> u32
fn to_u64(&self, rnd: RoundingMode) -> u64
fn to_i32(&self, rnd: RoundingMode) -> i32
fn to_i64(&self, rnd: RoundingMode) -> i64
fn to_f16(&self, rnd: RoundingMode) -> F16
fn to_f32(&self, rnd: RoundingMode) -> F32
fn to_f64(&self, rnd: RoundingMode) -> F64
fn to_f128(&self, rnd: RoundingMode) -> F128
fn round_to_integral(&self, rnd: RoundingMode) -> Self
Provided methods
fn compare<T: Borrow<Self>>(&self, x: T) -> Option<Ordering>
fn from_u8(x: u8, rnd: RoundingMode) -> Self where
Self: Sized,
Self: Sized,
fn from_u16(x: u16, rnd: RoundingMode) -> Self where
Self: Sized,
Self: Sized,
fn from_i8(x: i8, rnd: RoundingMode) -> Self where
Self: Sized,
Self: Sized,
fn from_i16(x: i16, rnd: RoundingMode) -> Self where
Self: Sized,
Self: Sized,
fn neg(&self) -> Self where
Self: Sized,
Self: Sized,
fn abs(&self) -> Self where
Self: Sized,
Self: Sized,
fn sign(&self) -> Self::Payload
fn exponent(&self) -> Self::Payload
fn fraction(&self) -> Self::Payload
fn is_positive(&self) -> bool
fn is_positive_zero(&self) -> bool
fn is_positive_subnormal(&self) -> bool
fn is_positive_normal(&self) -> bool
fn is_positive_infinity(&self) -> bool
fn is_negative(&self) -> bool
fn is_negative_zero(&self) -> bool
fn is_negative_subnormal(&self) -> bool
fn is_negative_normal(&self) -> bool
fn is_negative_infinity(&self) -> bool
fn is_nan(&self) -> bool
fn is_zero(&self) -> bool
fn is_subnormal(&self) -> bool
fn set_sign(&mut self, x: Self::Payload)
fn set_exponent(&mut self, x: Self::Payload)
fn set_fraction(&mut self, x: Self::Payload)
fn positive_infinity() -> Self where
Self: Sized,
Self: Sized,
fn positive_zero() -> Self where
Self: Sized,
Self: Sized,
fn negative_infinity() -> Self where
Self: Sized,
Self: Sized,
fn negative_zero() -> Self where
Self: Sized,
Self: Sized,
fn quiet_nan() -> Self where
Self: Sized,
Self: Sized,