Trait compiler_builtins::float::Float
source · 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§
Required Associated Constants§
const ZERO: Self
const ONE: Self
sourceconst SIGNIFICAND_BITS: u32
const SIGNIFICAND_BITS: u32
The bitwidth of the significand
sourceconst SIGNIFICAND_MASK: Self::Int
const SIGNIFICAND_MASK: Self::Int
A mask for the significand
const IMPLICIT_BIT: Self::Int
sourceconst EXPONENT_MASK: Self::Int
const EXPONENT_MASK: Self::Int
A mask for the exponent
Provided Associated Constants§
sourceconst EXPONENT_BITS: u32 = _
const EXPONENT_BITS: u32 = _
The bitwidth of the exponent
sourceconst EXPONENT_MAX: u32 = _
const EXPONENT_MAX: u32 = _
The maximum value of the exponent
sourceconst EXPONENT_BIAS: u32 = _
const EXPONENT_BIAS: u32 = _
The exponent bias value
Required Methods§
sourcefn signed_repr(self) -> Self::SignedInt
fn signed_repr(self) -> Self::SignedInt
Returns self
transmuted to Self::SignedInt
sourcefn eq_repr(self, rhs: Self) -> bool
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.
sourcefn frac(self) -> Self::Int
fn frac(self) -> Self::Int
Returns the significand with no implicit bit (or the “fractional” part)
sourcefn from_parts(sign: bool, exponent: Self::Int, significand: Self::Int) -> Self
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.
sourcefn normalize(significand: Self::Int) -> (i32, Self::Int)
fn normalize(significand: Self::Int) -> (i32, Self::Int)
Returns (normalized exponent, normalized significand)
sourcefn is_subnormal(self) -> bool
fn is_subnormal(self) -> bool
Returns if self
is subnormal