Skip to main content

ALPRDFloat

Trait ALPRDFloat 

Source
pub trait ALPRDFloat:
    Sealed
    + Float
    + Copy
    + NativePType {
    type UINT: NativePType + PrimInt + One + Copy;

    const BITS: usize = _;

    // Required methods
    fn from_bits(bits: Self::UINT) -> Self;
    fn to_bits(value: Self) -> Self::UINT;
    fn to_u16(bits: Self::UINT) -> u16;
    fn from_u16(value: u16) -> Self::UINT;
}
Expand description

Main trait for ALP-RD encodable floating point numbers.

Like the paper, we limit this to the IEEE7 754 single-precision (f32) and double-precision (f64) floating point types.

Provided Associated Constants§

Source

const BITS: usize = _

Number of bits the value occupies in registers.

Required Associated Types§

Source

type UINT: NativePType + PrimInt + One + Copy

The unsigned integer type with the same bit-width as the floating-point type.

Required Methods§

Source

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

Bit-wise transmute from the unsigned integer type to the floating-point type.

Source

fn to_bits(value: Self) -> Self::UINT

Bit-wise transmute into the unsigned integer type.

Source

fn to_u16(bits: Self::UINT) -> u16

Truncating conversion from the unsigned integer type to u16.

Source

fn from_u16(value: u16) -> Self::UINT

Type-widening conversion from u16 to the unsigned integer 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 ALPRDFloat for f32

Source§

type UINT = u32

Source§

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

Source§

fn to_bits(value: Self) -> Self::UINT

Source§

fn to_u16(bits: Self::UINT) -> u16

Source§

fn from_u16(value: u16) -> Self::UINT

Source§

impl ALPRDFloat for f64

Source§

type UINT = u64

Source§

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

Source§

fn to_bits(value: Self) -> Self::UINT

Source§

fn to_u16(bits: Self::UINT) -> u16

Source§

fn from_u16(value: u16) -> Self::UINT

Implementors§