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 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 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 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.

Implementations on Foreign Types§

source§

impl FloatBits for f64

§

type Item = u64

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 intervals::rounding::FloatBits>::Item}

source§

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

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 f32

§

type Item = u32

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 intervals::rounding::FloatBits>::Item}

source§

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

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§