ToBits

Trait ToBits 

Source
pub trait ToBits {
    type Bits: Eq + Hash + Copy;

    // Required method
    fn to_bits(self) -> Self::Bits;
}
Expand description

Generic trait for converting floating-point types to their IEEE 754 bit representation.

Unifies access to a to_bits method across different floating-point types, enabling generic operation on floating-point bit patterns.

§Type Parameters

The associated Bits type represents the unsigned integer type with equivalent bit width to the floating-point type, supporting equality comparison and hashing.

§Implementation Requirements

Implementations must preserve IEEE 754 bit layout and handle special values (NaN, infinity, signed zero) according to standard specifications.

Required Associated Types§

Source

type Bits: Eq + Hash + Copy

The unsigned integer type representing the bit pattern.

Must be the same bit width as the floating-point type and support equality comparison and hashing for use in collections.

Required Methods§

Source

fn to_bits(self) -> Self::Bits

Converts the floating-point value to its IEEE 754 bit representation.

Returns the raw bit pattern as an unsigned integer, preserving all floating-point special values and sign information.

§Examples
use simd_kernels::traits::to_bits::ToBits;

let f = 3.14f32;
let bits = f.to_bits(); // Returns u32 bit representation

Implementations on Foreign Types§

Source§

impl ToBits for f32

Implementation for 32-bit IEEE 754 single-precision floating-point values.

Maps to the corresponding 32-bit unsigned integer bit pattern, preserving all floating-point special values including NaN bit patterns and signed zeros.

Source§

impl ToBits for f64

Implementation for 64-bit IEEE 754 double-precision floating-point values.

Maps to the corresponding 64-bit unsigned integer bit pattern, preserving all floating-point special values including NaN bit patterns and signed zeros.

Implementors§