Skip to main content

ALPFloat

Trait ALPFloat 

Source
pub trait ALPFloat:
    Sealed
    + Float
    + Display
    + NativePType {
    type ALPInt: PrimInt + Display + ToPrimitive + Copy + NativePType + Into<PValue>;

    const FRACTIONAL_BITS: u8;
    const MAX_EXPONENT: u8;
    const SWEET: Self;
    const F10: &'static [Self];
    const IF10: &'static [Self];
Show 15 methods // Required methods fn as_int(self) -> Self::ALPInt; fn from_int(n: Self::ALPInt) -> Self; // Provided methods fn fast_round(self) -> Self { ... } fn find_best_exponents(values: &[Self]) -> Exponents { ... } fn estimate_encoded_size( encoded: &[Self::ALPInt], patches: &[Self], ) -> usize { ... } fn encode( values: &[Self], exponents: Option<Exponents>, ) -> (Exponents, Buffer<Self::ALPInt>, Buffer<u64>, Buffer<Self>, BufferMut<u64>) { ... } fn encode_single(value: Self, exponents: Exponents) -> Option<Self::ALPInt> { ... } fn encode_above(value: Self, exponents: Exponents) -> Self::ALPInt { ... } fn encode_below(value: Self, exponents: Exponents) -> Self::ALPInt { ... } fn decode(encoded: &[Self::ALPInt], exponents: Exponents) -> Vec<Self> { ... } fn decode_buffer( encoded: BufferMut<Self::ALPInt>, exponents: Exponents, ) -> BufferMut<Self> { ... } fn decode_into( encoded: &[Self::ALPInt], exponents: Exponents, output: &mut [Self], ) { ... } fn decode_slice_inplace(encoded: &mut [Self::ALPInt], exponents: Exponents) { ... } fn decode_single(encoded: Self::ALPInt, exponents: Exponents) -> Self { ... } fn encode_single_unchecked( value: Self, exponents: Exponents, ) -> Self::ALPInt { ... }
}

Required Associated Constants§

Source

const FRACTIONAL_BITS: u8

Source

const MAX_EXPONENT: u8

Source

const SWEET: Self

Source

const F10: &'static [Self]

Source

const IF10: &'static [Self]

Required Associated Types§

Required Methods§

Source

fn as_int(self) -> Self::ALPInt

Equivalent to calling as to cast the primitive float to the target integer type.

Source

fn from_int(n: Self::ALPInt) -> Self

Convert from the integer type back to the float type using as.

Provided Methods§

Source

fn fast_round(self) -> Self

Round to the nearest floating integer by shifting in and out of the low precision range.

Source

fn find_best_exponents(values: &[Self]) -> Exponents

Source

fn estimate_encoded_size(encoded: &[Self::ALPInt], patches: &[Self]) -> usize

Source

fn encode( values: &[Self], exponents: Option<Exponents>, ) -> (Exponents, Buffer<Self::ALPInt>, Buffer<u64>, Buffer<Self>, BufferMut<u64>)

Source

fn encode_single(value: Self, exponents: Exponents) -> Option<Self::ALPInt>

Source

fn encode_above(value: Self, exponents: Exponents) -> Self::ALPInt

Source

fn encode_below(value: Self, exponents: Exponents) -> Self::ALPInt

Source

fn decode(encoded: &[Self::ALPInt], exponents: Exponents) -> Vec<Self>

Source

fn decode_buffer( encoded: BufferMut<Self::ALPInt>, exponents: Exponents, ) -> BufferMut<Self>

Source

fn decode_into( encoded: &[Self::ALPInt], exponents: Exponents, output: &mut [Self], )

Source

fn decode_slice_inplace(encoded: &mut [Self::ALPInt], exponents: Exponents)

Source

fn decode_single(encoded: Self::ALPInt, exponents: Exponents) -> Self

Source

fn encode_single_unchecked(value: Self, exponents: Exponents) -> Self::ALPInt

Encode single float value. The returned value might decode to a different value than passed in. Consider using Self::encode_single if you want the checked version of this function.

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 ALPFloat for f32

Source§

const FRACTIONAL_BITS: u8 = 23

Source§

const MAX_EXPONENT: u8 = 10

Source§

const SWEET: Self

Source§

const F10: &'static [Self]

Source§

const IF10: &'static [Self]

Source§

type ALPInt = i32

Source§

fn as_int(self) -> Self::ALPInt

Source§

fn from_int(n: Self::ALPInt) -> Self

Source§

impl ALPFloat for f64

Source§

const FRACTIONAL_BITS: u8 = 52

Source§

const MAX_EXPONENT: u8 = 18

Source§

const SWEET: Self

Source§

const F10: &'static [Self]

Source§

const IF10: &'static [Self]

Source§

type ALPInt = i64

Source§

fn as_int(self) -> Self::ALPInt

Source§

fn from_int(n: Self::ALPInt) -> Self

Implementors§