Struct checked_float::CheckedFloat
source · pub struct CheckedFloat<T: Float, C: FloatChecker<T>>(_, _);Expand description
A checked floating point type.
Every instance of CheckedFloat is guaranteed to satisfy the property given by the provided FloatChecker.
In particular, this can be used to have a floating point type that forbids values like
NaN, infinity, negatives, etc. all by providing different checkers.
CheckedFloat supports all the typical operations of a normal float type.
However, all operations that yield another float type (e.g., add, sub, sin, etc.)
instead yield a custom Result type specified by the FloatChecker.
All methods from the Float type are supported by this wrapper in checked context.
For documentation, see the original method definitions in Float.
CheckedFloat also supports an implementation of Ord, which allows for directly sorting CheckedFloat collections.
The convention for this implementation has ordering -NaN < -Inf < ... < -0 = +0 < ... < +Inf < +NaN.
CheckedFloat::get can be used to get the underlying float value.
Implementations§
source§impl<T: Float, C: FloatChecker<T>> CheckedFloat<T, C>
impl<T: Float, C: FloatChecker<T>> CheckedFloat<T, C>
pub fn new(value: T) -> Result<Self, C::Error>
pub fn get(self) -> T
pub fn classify(self) -> FpCategory
pub fn integer_decode(self) -> (u64, i16, i8)
pub fn is_finite(self) -> bool
pub fn is_infinite(self) -> bool
pub fn is_nan(self) -> bool
pub fn is_normal(self) -> bool
pub fn is_sign_negative(self) -> bool
pub fn is_sign_positive(self) -> bool
pub fn is_zero(self) -> bool
pub fn is_one(self) -> bool
pub fn infinity() -> Result<Self, C::Error>
pub fn max_value() -> Result<Self, C::Error>
pub fn min_positive_value() -> Result<Self, C::Error>
pub fn min_value() -> Result<Self, C::Error>
pub fn nan() -> Result<Self, C::Error>
pub fn neg_infinity() -> Result<Self, C::Error>
pub fn neg_zero() -> Result<Self, C::Error>
pub fn zero() -> Result<Self, C::Error>
pub fn one() -> Result<Self, C::Error>
pub fn epsilon() -> Result<Self, C::Error>
pub fn abs(self) -> Result<Self, C::Error>
pub fn acos(self) -> Result<Self, C::Error>
pub fn acosh(self) -> Result<Self, C::Error>
pub fn asin(self) -> Result<Self, C::Error>
pub fn asinh(self) -> Result<Self, C::Error>
pub fn atan(self) -> Result<Self, C::Error>
pub fn atanh(self) -> Result<Self, C::Error>
pub fn cbrt(self) -> Result<Self, C::Error>
pub fn ceil(self) -> Result<Self, C::Error>
pub fn cos(self) -> Result<Self, C::Error>
pub fn cosh(self) -> Result<Self, C::Error>
pub fn exp(self) -> Result<Self, C::Error>
pub fn exp2(self) -> Result<Self, C::Error>
pub fn exp_m1(self) -> Result<Self, C::Error>
pub fn floor(self) -> Result<Self, C::Error>
pub fn fract(self) -> Result<Self, C::Error>
pub fn ln(self) -> Result<Self, C::Error>
pub fn ln_1p(self) -> Result<Self, C::Error>
pub fn log10(self) -> Result<Self, C::Error>
pub fn log2(self) -> Result<Self, C::Error>
pub fn neg(self) -> Result<Self, C::Error>
pub fn recip(self) -> Result<Self, C::Error>
pub fn round(self) -> Result<Self, C::Error>
pub fn signum(self) -> Result<Self, C::Error>
pub fn sin(self) -> Result<Self, C::Error>
pub fn sinh(self) -> Result<Self, C::Error>
pub fn sqrt(self) -> Result<Self, C::Error>
pub fn tan(self) -> Result<Self, C::Error>
pub fn tanh(self) -> Result<Self, C::Error>
pub fn trunc(self) -> Result<Self, C::Error>
pub fn to_degrees(self) -> Result<Self, C::Error>
pub fn to_radians(self) -> Result<Self, C::Error>
pub fn abs_sub(self, other: Self) -> Result<Self, C::Error>
pub fn add(self, other: Self) -> Result<Self, C::Error>
pub fn atan2(self, other: Self) -> Result<Self, C::Error>
pub fn div(self, other: Self) -> Result<Self, C::Error>
pub fn hypot(self, other: Self) -> Result<Self, C::Error>
pub fn log(self, base: Self) -> Result<Self, C::Error>
pub fn mul(self, other: Self) -> Result<Self, C::Error>
pub fn powf(self, n: Self) -> Result<Self, C::Error>
pub fn rem(self, other: Self) -> Result<Self, C::Error>
pub fn sub(self, other: Self) -> Result<Self, C::Error>
pub fn copysign(self, sign: Self) -> Result<Self, C::Error>
pub fn mul_add(self, a: Self, b: Self) -> Result<Self, C::Error>
pub fn powi(self, n: i32) -> Result<Self, C::Error>
pub fn sin_cos(self) -> (Result<Self, C::Error>, Result<Self, C::Error>)
Trait Implementations§
source§impl<T: Float, C: FloatChecker<T>> Clone for CheckedFloat<T, C>
impl<T: Float, C: FloatChecker<T>> Clone for CheckedFloat<T, C>
source§impl<T: Float + Debug, C: FloatChecker<T>> Debug for CheckedFloat<T, C>
impl<T: Float + Debug, C: FloatChecker<T>> Debug for CheckedFloat<T, C>
source§impl<T: Float + Display, C: FloatChecker<T>> Display for CheckedFloat<T, C>
impl<T: Float + Display, C: FloatChecker<T>> Display for CheckedFloat<T, C>
source§impl<T: Float, C: FloatChecker<T>> Ord for CheckedFloat<T, C>
impl<T: Float, C: FloatChecker<T>> Ord for CheckedFloat<T, C>
source§impl<T: Float, C: FloatChecker<T>> PartialEq<CheckedFloat<T, C>> for CheckedFloat<T, C>
impl<T: Float, C: FloatChecker<T>> PartialEq<CheckedFloat<T, C>> for CheckedFloat<T, C>
source§impl<T: Float, C: FloatChecker<T>> PartialOrd<CheckedFloat<T, C>> for CheckedFloat<T, C>
impl<T: Float, C: FloatChecker<T>> PartialOrd<CheckedFloat<T, C>> for CheckedFloat<T, C>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read more