pub(crate) trait Float: Copy + Debug + PartialEq + PartialOrd + AddAssign + MulAssign + Add<Output = Self> + Sub<Output = Self> + Div<Output = Self> + Rem<Output = Self> {
    type Int: Int;
    type SignedInt: Int;
    type ExpInt: Int;
Show 11 associated constants and 11 methods const ZERO: Self; const ONE: Self; const BITS: u32; const SIGNIFICAND_BITS: u32; const SIGN_MASK: Self::Int; const SIGNIFICAND_MASK: Self::Int; const IMPLICIT_BIT: Self::Int; const EXPONENT_MASK: Self::Int; const EXPONENT_BITS: u32 = _; const EXPONENT_MAX: u32 = _; const EXPONENT_BIAS: u32 = _; // Required methods fn repr(self) -> Self::Int; fn signed_repr(self) -> Self::SignedInt; fn eq_repr(self, rhs: Self) -> bool; fn sign(self) -> bool; fn exp(self) -> Self::ExpInt; fn frac(self) -> Self::Int; fn imp_frac(self) -> Self::Int; fn from_repr(a: Self::Int) -> Self; fn from_parts( sign: bool, exponent: Self::Int, significand: Self::Int ) -> Self; fn normalize(significand: Self::Int) -> (i32, Self::Int); fn is_subnormal(self) -> bool;
}
Expand description

Trait for some basic operations on floats

Required Associated Types§

source

type Int: Int

A uint of the same width as the float

source

type SignedInt: Int

A int of the same width as the float

source

type ExpInt: Int

An int capable of containing the exponent bits plus a sign bit. This is signed.

Required Associated Constants§

source

const ZERO: Self

source

const ONE: Self

source

const BITS: u32

The bitwidth of the float type

source

const SIGNIFICAND_BITS: u32

The bitwidth of the significand

source

const SIGN_MASK: Self::Int

A mask for the sign bit

source

const SIGNIFICAND_MASK: Self::Int

A mask for the significand

source

const IMPLICIT_BIT: Self::Int

source

const EXPONENT_MASK: Self::Int

A mask for the exponent

Provided Associated Constants§

source

const EXPONENT_BITS: u32 = _

The bitwidth of the exponent

source

const EXPONENT_MAX: u32 = _

The maximum value of the exponent

source

const EXPONENT_BIAS: u32 = _

The exponent bias value

Required Methods§

source

fn repr(self) -> Self::Int

Returns self transmuted to Self::Int

source

fn signed_repr(self) -> Self::SignedInt

Returns self transmuted to Self::SignedInt

source

fn eq_repr(self, rhs: Self) -> bool

Checks if two floats have the same bit representation. Except for NaNs! NaN can be represented in multiple different ways. This method returns true if two NaNs are compared.

source

fn sign(self) -> bool

Returns the sign bit

source

fn exp(self) -> Self::ExpInt

Returns the exponent with bias

source

fn frac(self) -> Self::Int

Returns the significand with no implicit bit (or the “fractional” part)

source

fn imp_frac(self) -> Self::Int

Returns the significand with implicit bit

source

fn from_repr(a: Self::Int) -> Self

Returns a Self::Int transmuted back to Self

source

fn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self

Constructs a Self from its parts. Inputs are treated as bits and shifted into position.

source

fn normalize(significand: Self::Int) -> (i32, Self::Int)

Returns (normalized exponent, normalized significand)

source

fn is_subnormal(self) -> bool

Returns if self is subnormal

Implementations on Foreign Types§

source§

impl Float for f32

§

type Int = u32

§

type SignedInt = i32

§

type ExpInt = i16

source§

const ZERO: Self = 0f32

source§

const ONE: Self = 1f32

source§

const BITS: u32 = 32u32

source§

const SIGNIFICAND_BITS: u32 = 23u32

source§

const SIGN_MASK: Self::Int = {transmute(0x80000000): <f32 as float::Float>::Int}

source§

const SIGNIFICAND_MASK: Self::Int = {transmute(0x007fffff): <f32 as float::Float>::Int}

source§

const IMPLICIT_BIT: Self::Int = {transmute(0x00800000): <f32 as float::Float>::Int}

source§

const EXPONENT_MASK: Self::Int = {transmute(0x7f800000): <f32 as float::Float>::Int}

source§

fn repr(self) -> Self::Int

source§

fn signed_repr(self) -> Self::SignedInt

source§

fn eq_repr(self, rhs: Self) -> bool

source§

fn sign(self) -> bool

source§

fn exp(self) -> Self::ExpInt

source§

fn frac(self) -> Self::Int

source§

fn imp_frac(self) -> Self::Int

source§

fn from_repr(a: Self::Int) -> Self

source§

fn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self

source§

fn normalize(significand: Self::Int) -> (i32, Self::Int)

source§

fn is_subnormal(self) -> bool

source§

impl Float for f64

§

type Int = u64

§

type SignedInt = i64

§

type ExpInt = i16

source§

const ZERO: Self = 0f64

source§

const ONE: Self = 1f64

source§

const BITS: u32 = 64u32

source§

const SIGNIFICAND_BITS: u32 = 52u32

source§

const SIGN_MASK: Self::Int = {transmute(0x8000000000000000): <f64 as float::Float>::Int}

source§

const SIGNIFICAND_MASK: Self::Int = {transmute(0x000fffffffffffff): <f64 as float::Float>::Int}

source§

const IMPLICIT_BIT: Self::Int = {transmute(0x0010000000000000): <f64 as float::Float>::Int}

source§

const EXPONENT_MASK: Self::Int = {transmute(0x7ff0000000000000): <f64 as float::Float>::Int}

source§

fn repr(self) -> Self::Int

source§

fn signed_repr(self) -> Self::SignedInt

source§

fn eq_repr(self, rhs: Self) -> bool

source§

fn sign(self) -> bool

source§

fn exp(self) -> Self::ExpInt

source§

fn frac(self) -> Self::Int

source§

fn imp_frac(self) -> Self::Int

source§

fn from_repr(a: Self::Int) -> Self

source§

fn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self

source§

fn normalize(significand: Self::Int) -> (i32, Self::Int)

source§

fn is_subnormal(self) -> bool

Implementors§