pub trait Float: Sealed + Copy + Clone + PartialEq + PartialOrd + Add<Self, Output = Self> + Sub<Self, Output = Self> + Div<Self, Output = Self> + Mul<Self, Output = Self> {
fn from_usize(v: usize) -> Self;
fn from_float<F: Float>(v: F) -> Self;
fn to_f64(self) -> f64;
fn infinity() -> Self;
fn max_value() -> Self;
fn sqrt(self) -> Self;
fn abs(self) -> Self;
}
Expand description
A trait for writing generic code over floating point numbers.
We used to use the corresponding trait from the num-traits
crate, but for
operational simplicity, we provide our own trait to avoid the dependency.
This trait is sealed. Callers therefore can not implement it. It is only
implemented for the f32
and f64
types.
Required Methods§
sourcefn from_usize(v: usize) -> Self
fn from_usize(v: usize) -> Self
Converts a usize
to a float.
sourcefn from_float<F: Float>(v: F) -> Self
fn from_float<F: Float>(v: F) -> Self
Converts any floating type to this one.