pub trait Float:
    Copy
    + Debug
    + PartialEq
    + PartialOrd
    + AddAssign
    + MulAssign
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Rem<Output = Self>
    + Neg<Output = Self>
    + 'static {
    type Int: Int<OtherSign = Self::SignedInt, Unsigned = Self::Int>;
    type SignedInt: Int + MinInt<OtherSign = Self::Int, Unsigned = Self::Int> + Neg<Output = Self::SignedInt>;
Show 27 associated constants and 19 methods const ZERO: Self; const NEG_ZERO: Self; const ONE: Self; const NEG_ONE: Self; const INFINITY: Self; const NEG_INFINITY: Self; const NAN: Self; const NEG_NAN: Self; const MAX: Self; const MIN: Self; const EPSILON: Self; const PI: Self; const NEG_PI: Self; const FRAC_PI_2: Self; const MIN_POSITIVE_NORMAL: Self; const BITS: u32; const SIG_BITS: u32; const SIGN_MASK: Self::Int; const SIG_MASK: Self::Int; const EXP_MASK: Self::Int; const IMPLICIT_BIT: Self::Int; const EXP_BITS: u32 = _; const EXP_SAT: u32 = _; const EXP_BIAS: u32 = _; const EXP_MAX: i32 = _; const EXP_MIN: i32 = _; const EXP_MIN_SUBNORM: i32 = _; // Required methods fn to_bits(self) -> Self::Int; fn is_nan(self) -> bool; fn is_infinite(self) -> bool; fn is_sign_negative(self) -> bool; fn from_bits(a: Self::Int) -> Self; fn abs(self) -> Self; fn copysign(self, other: Self) -> Self; fn fma(self, y: Self, z: Self) -> Self; fn normalize(significand: Self::Int) -> (i32, Self::Int); // Provided methods fn to_bits_signed(self) -> Self::SignedInt { ... } fn biteq(self, rhs: Self) -> bool { ... } fn eq_repr(self, rhs: Self) -> bool { ... } fn is_sign_positive(self) -> bool { ... } fn is_subnormal(self) -> bool { ... } fn ex(self) -> u32 { ... } fn exp_unbiased(self) -> i32 { ... } fn frac(self) -> Self::Int { ... } fn from_parts(negative: bool, exponent: u32, significand: Self::Int) -> Self { ... } fn signum(self) -> Self { ... }
}
Expand description

Trait for some basic operations on floats

Required Associated Constants§

Source

const ZERO: Self

Source

const NEG_ZERO: Self

Source

const ONE: Self

Source

const NEG_ONE: Self

Source

const INFINITY: Self

Source

const NEG_INFINITY: Self

Source

const NAN: Self

Source

const NEG_NAN: Self

Source

const MAX: Self

Source

const MIN: Self

Source

const EPSILON: Self

Source

const PI: Self

Source

const NEG_PI: Self

Source

const FRAC_PI_2: Self

Source

const MIN_POSITIVE_NORMAL: Self

Source

const BITS: u32

The bitwidth of the float type

Source

const SIG_BITS: u32

The bitwidth of the significand

Source

const SIGN_MASK: Self::Int

A mask for the sign bit

Source

const SIG_MASK: Self::Int

A mask for the significand

Source

const EXP_MASK: Self::Int

A mask for the exponent

Source

const IMPLICIT_BIT: Self::Int

The implicit bit of the float format

Provided Associated Constants§

Source

const EXP_BITS: u32 = _

The bitwidth of the exponent

Source

const EXP_SAT: u32 = _

The saturated (maximum bitpattern) value of the exponent, i.e. the infinite representation.

This shifted fully right, use EXP_MASK for the shifted value.

Source

const EXP_BIAS: u32 = _

The exponent bias value

Source

const EXP_MAX: i32 = _

Maximum unbiased exponent value.

Source

const EXP_MIN: i32 = _

Minimum NORMAL unbiased exponent value.

Source

const EXP_MIN_SUBNORM: i32 = _

Minimum subnormal exponent value.

Required Associated Types§

Source

type Int: Int<OtherSign = Self::SignedInt, Unsigned = Self::Int>

A uint of the same width as the float

Source

type SignedInt: Int + MinInt<OtherSign = Self::Int, Unsigned = Self::Int> + Neg<Output = Self::SignedInt>

A int of the same width as the float

Required Methods§

Source

fn to_bits(self) -> Self::Int

Returns self transmuted to Self::Int

Source

fn is_nan(self) -> bool

Returns true if the value is NaN.

Source

fn is_infinite(self) -> bool

Returns true if the value is +inf or -inf.

Source

fn is_sign_negative(self) -> bool

Returns true if the sign is negative. Extracts the sign bit regardless of zero or NaN.

Source

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

Returns a Self::Int transmuted back to Self

Source

fn abs(self) -> Self

Source

fn copysign(self, other: Self) -> Self

Returns a number composed of the magnitude of self and the sign of sign.

Source

fn fma(self, y: Self, z: Self) -> Self

Fused multiply add, rounding once.

Source

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

Returns (normalized exponent, normalized significand)

Provided Methods§

Source

fn to_bits_signed(self) -> Self::SignedInt

Returns self transmuted to Self::SignedInt

Source

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

Check bitwise equality.

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. Use biteq instead if NaN should not be treated separately.

Source

fn is_sign_positive(self) -> bool

Returns true if the sign is positive. Extracts the sign bit regardless of zero or NaN.

Source

fn is_subnormal(self) -> bool

Returns if self is subnormal.

Source

fn ex(self) -> u32

Returns the exponent, not adjusting for bias, not accounting for subnormals or zero.

Source

fn exp_unbiased(self) -> i32

Extract the exponent and adjust it for bias, not accounting for subnormals or zero.

Source

fn frac(self) -> Self::Int

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

Source

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

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

Source

fn signum(self) -> Self

Returns a number that represents the sign of self.

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.

Implementors§