Trait umath::Float

source ·
pub trait Float<F>: PartialOrd<F> + FloatAlone + Add<F, Output = Self> + Sub<F, Output = Self> + Mul<F, Output = Self> + Rem<F, Output = Self> + Div<F, Output = Self> + AddAssign<F> + SubAssign<F> + MulAssign<F> + DivAssign<F> + RemAssign<F>where
    Self: Sized,{
    // Required methods
    unsafe fn new(from: F) -> Self;
    fn take(self) -> F;
}
Expand description

Generic float trait, implemented by {FFloat, f32, f64}. Takes a “base” argument, intended to be set to {f32, f64}. The main purpose of this is to be taken (generically) by optionally fast functions.

Safety

Please note that calling these functions on a FFloat may incur UB. These functions are not marked unsafe, as the entire FFloat type is essentially unsafe. Calling these functions on a f32 is perfectly safe, even the unsafe marked functions (although theres not much point in doing so).

Required Methods§

source

unsafe fn new(from: F) -> Self

Returns a new Self from the float.

Safety

Refer to Self’s safety documentation. This function is unsafe only when used with a FFloat; Calling it with a f64 or a f32 is safe.

source

fn take(self) -> F

Returns this float

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Float<f32> for f32

source§

unsafe fn new(from: f32) -> f32

Returns the input value. This function is safe to call.

source§

fn take(self) -> f32

source§

impl Float<f64> for f64

source§

unsafe fn new(from: f64) -> f64

Returns the input value. This function is safe to call.

source§

fn take(self) -> f64

Implementors§

source§

impl<F: FastFloat + Float<F>> Float<F> for FFloat<F>