Skip to main content

Float

Trait Float 

Source
pub trait Float:
    Float
    + Sealed
    + KernelItem
    + Source<Self> {
    type Working: Native;
    type OrderKey: RadixKey + Key;

    // Required methods
    fn working(self) -> Self::Working;
    fn from_working(t: Self::Working) -> Self;
    fn wide(self) -> f64;
    fn narrow(x: f64) -> Self;
    fn next_up(self) -> Self;
    fn next_down(self) -> Self;
    fn round_ties_even(self) -> Self;
    fn order_key(self) -> Self::OrderKey;
    fn total_key(self) -> Self::OrderKey;
    fn from_order_key(k: Self::OrderKey) -> Self;
    fn choose(
        x: Arg<'_, Self>,
        y: Arg<'_, Self>,
        mask: Arg<'_, Self>,
        n: usize,
        out: &mut Slots<'_, Self>,
    ) -> bool;
}
Expand description

A float type that rustymath’s functions take: half::f16, f32 or f64.

Required Associated Types§

Source

type Working: Native

The type this float computes in, its working precision: f32 for f16, and the type itself otherwise. A function of an f16 computes in f32 and rounds once. Sums keep their running totals in this type.

Source

type OrderKey: RadixKey + Key

The unsigned type, of this float’s width, that order_key gives.

Required Methods§

Source

fn working(self) -> Self::Working

This float in its working type, which holds it exactly.

Source

fn from_working(t: Self::Working) -> Self

t rounded to this type.

Source

fn wide(self) -> f64

This float as an f64, which holds it exactly.

Source

fn narrow(x: f64) -> Self

x rounded to the nearest float of this type.

Source

fn next_up(self) -> Self

The least float of this type above self, as f64::next_up gives it.

Source

fn next_down(self) -> Self

The greatest float of this type below self, as f64::next_down gives it.

Source

fn round_ties_even(self) -> Self

Rounds to the nearest whole number, with ties to even.

Source

fn order_key(self) -> Self::OrderKey

A key whose unsigned order is the order of total_cmp, after ¯0 becomes 0 and every NaN becomes one NaN. So ¯0 and 0 share a key, NaN’s key follows every other, and two floats match exactly when their keys are equal.

Source

fn total_key(self) -> Self::OrderKey

A key whose unsigned order is the order of total_cmp, after every NaN becomes positive. So ¯0’s key comes just before 0’s, every NaN’s follows ∞’s, and from_order_key reads the float back exactly, apart from a NaN’s sign. Sorts and selections compare these keys and write floats back from them.

Source

fn from_order_key(k: Self::OrderKey) -> Self

The float whose order_key or total_key is k. A total key reads back exactly, apart from a NaN’s sign. An order key reads ¯0 back as 0, and every NaN as one NaN.

Source

fn choose( x: Arg<'_, Self>, y: Arg<'_, Self>, mask: Arg<'_, Self>, n: usize, out: &mut Slots<'_, Self>, ) -> bool

Writes x where mask’s lanes aren’t zero and y where they are into the next n slots of out, through Choose, and gives whether every result succeeded. Fused graphs pass a comparison’s lanes of 1 and 0 as the mask.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Float for f16

Source§

type Working = f32

Source§

type OrderKey = u16

Source§

fn working(self) -> f32

Source§

fn from_working(t: f32) -> Self

Source§

fn wide(self) -> f64

Source§

fn narrow(x: f64) -> Self

Source§

fn choose( x: Arg<'_, Self>, y: Arg<'_, Self>, mask: Arg<'_, Self>, n: usize, out: &mut Slots<'_, Self>, ) -> bool

Source§

fn next_up(self) -> Self

Source§

fn next_down(self) -> Self

Source§

fn round_ties_even(self) -> Self

Source§

fn order_key(self) -> u16

Source§

fn total_key(self) -> u16

Source§

fn from_order_key(k: u16) -> Self

Source§

impl Float for f32

Source§

type Working = f32

Source§

type OrderKey = u32

Source§

fn working(self) -> f32

Source§

fn from_working(t: f32) -> f32

Source§

fn wide(self) -> f64

Source§

fn narrow(x: f64) -> f32

Source§

fn choose( x: Arg<'_, f32>, y: Arg<'_, f32>, mask: Arg<'_, f32>, n: usize, out: &mut Slots<'_, f32>, ) -> bool

Source§

fn next_up(self) -> f32

Source§

fn next_down(self) -> f32

Source§

fn round_ties_even(self) -> Self

Source§

fn order_key(self) -> u32

Source§

fn total_key(self) -> u32

Source§

fn from_order_key(k: u32) -> Self

Source§

impl Float for f64

Source§

type Working = f64

Source§

type OrderKey = u64

Source§

fn working(self) -> f64

Source§

fn from_working(t: f64) -> f64

Source§

fn wide(self) -> f64

Source§

fn narrow(x: f64) -> f64

Source§

fn choose( x: Arg<'_, f64>, y: Arg<'_, f64>, mask: Arg<'_, f64>, n: usize, out: &mut Slots<'_, f64>, ) -> bool

Source§

fn next_up(self) -> f64

Source§

fn next_down(self) -> f64

Source§

fn round_ties_even(self) -> Self

Source§

fn order_key(self) -> u64

Source§

fn total_key(self) -> u64

Source§

fn from_order_key(k: u64) -> Self

Implementors§