datafusion_common::rounding

Trait FloatBits

Source
pub trait FloatBits {
    type Item: Copy + PartialEq + BitAnd<Output = Self::Item> + Add<Output = Self::Item> + Sub<Output = Self::Item>;

    const TINY_BITS: Self::Item;
    const NEG_TINY_BITS: Self::Item;
    const CLEAR_SIGN_MASK: Self::Item;
    const ONE: Self::Item;
    const ZERO: Self::Item;

    // Required methods
    fn to_bits(self) -> Self::Item;
    fn from_bits(bits: Self::Item) -> Self;
    fn float_is_nan(self) -> bool;
    fn infinity() -> Self;
    fn neg_infinity() -> Self;
}
Expand description

A trait to manipulate floating-point types with bitwise operations. Provides functions to convert a floating-point value to/from its bitwise representation as well as utility methods to handle special values.

Required Associated Constants§

Source

const TINY_BITS: Self::Item

The smallest positive floating-point value representable by this type.

Source

const NEG_TINY_BITS: Self::Item

The smallest (in magnitude) negative floating-point value representable by this type.

Source

const CLEAR_SIGN_MASK: Self::Item

A mask to clear the sign bit of the floating-point value’s bitwise representation.

Source

const ONE: Self::Item

The integer value 1, used in bitwise operations.

Source

const ZERO: Self::Item

The integer value 0, used in bitwise operations.

Required Associated Types§

Source

type Item: Copy + PartialEq + BitAnd<Output = Self::Item> + Add<Output = Self::Item> + Sub<Output = Self::Item>

The integer type used for bitwise operations.

Required Methods§

Source

fn to_bits(self) -> Self::Item

Converts the floating-point value to its bitwise representation.

Source

fn from_bits(bits: Self::Item) -> Self

Converts the bitwise representation to the corresponding floating-point value.

Source

fn float_is_nan(self) -> bool

Returns true if the floating-point value is NaN (not a number).

Source

fn infinity() -> Self

Returns the positive infinity value for this floating-point type.

Source

fn neg_infinity() -> Self

Returns the negative infinity value for this floating-point type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl FloatBits for f32

Source§

const TINY_BITS: u32 = 1u32

Source§

const NEG_TINY_BITS: u32 = 2_147_483_649u32

Source§

const CLEAR_SIGN_MASK: u32 = 2_147_483_647u32

Source§

const ONE: Self::Item = {transmute(0x00000001): <f32 as rounding::FloatBits>::Item}

Source§

const ZERO: Self::Item = {transmute(0x00000000): <f32 as rounding::FloatBits>::Item}

Source§

type Item = u32

Source§

fn to_bits(self) -> Self::Item

Source§

fn from_bits(bits: Self::Item) -> Self

Source§

fn float_is_nan(self) -> bool

Source§

fn infinity() -> Self

Source§

fn neg_infinity() -> Self

Source§

impl FloatBits for f64

Source§

const TINY_BITS: u64 = 1u64

Source§

const NEG_TINY_BITS: u64 = 9_223_372_036_854_775_809u64

Source§

const CLEAR_SIGN_MASK: u64 = 9_223_372_036_854_775_807u64

Source§

const ONE: Self::Item = {transmute(0x0000000000000001): <f64 as rounding::FloatBits>::Item}

Source§

const ZERO: Self::Item = {transmute(0x0000000000000000): <f64 as rounding::FloatBits>::Item}

Source§

type Item = u64

Source§

fn to_bits(self) -> Self::Item

Source§

fn from_bits(bits: Self::Item) -> Self

Source§

fn float_is_nan(self) -> bool

Source§

fn infinity() -> Self

Source§

fn neg_infinity() -> Self

Implementors§