Skip to main content

FloatingPoint

Trait FloatingPoint 

Source
pub unsafe trait FloatingPoint
where Self: Add<Output = Self> + AddAssign + Arithmetic + Div<Output = Self> + DivAssign + Mul<Output = Self> + MulAssign + Neg<Output = Self> + Rem<Output = Self> + RemAssign + Sub<Output = Self> + SubAssign,
{ type Bits: Unsigned;
Show 35 associated constants and 23 methods const DIGITS: u32; const E: Self; const EPSILON: Self; const EULER_GAMMA: Self; const FRAC_1_PI: Self; const FRAC_1_SQRT_2: Self; const FRAC_2_PI: Self; const FRAC_2_SQRT_PI: Self; const FRAC_PI_2: Self; const FRAC_PI_3: Self; const FRAC_PI_4: Self; const FRAC_PI_6: Self; const FRAC_PI_8: Self; const GOLDEN_RATIO: Self; const INFINITY: Self; const LN_10: Self; const LN_2: Self; const LOG10_2: Self; const LOG10_E: Self; const LOG2_10: Self; const LOG2_E: Self; const MANTISSA_DIGITS: u32; const MAX: Self; const MAX_10_EXP: i32; const MAX_EXP: i32; const MIN: Self; const MIN_10_EXP: i32; const MIN_EXP: i32; const MIN_POSITIVE: Self; const NAN: Self; const NEG_INFINITY: Self; const PI: Self; const RADIX: u32; const SQRT_2: Self; const TAU: Self; // Required methods fn abs(self) -> Self; fn clamp(self, min: Self, max: Self) -> Self; fn classify(self) -> FpCategory; fn copysign(self, rhs: Self) -> Self; fn from_bits(bits: Self::Bits) -> Self; fn is_finite(self) -> bool; fn is_infinite(self) -> bool; fn is_nan(self) -> bool; fn is_normal(self) -> bool; fn is_sign_negative(self) -> bool; fn is_sign_positive(self) -> bool; fn is_subnormal(self) -> bool; fn max(self, rhs: Self) -> Self; fn midpoint(self, rhs: Self) -> Self; fn min(self, rhs: Self) -> Self; fn next_down(self) -> Self; fn next_up(self) -> Self; fn recip(self) -> Self; fn signum(self) -> Self; fn to_bits(self) -> Self::Bits; fn to_degrees(self) -> Self; fn to_radians(self) -> Self; fn total_cmp(&self, rhs: &Self) -> Ordering;
}
Expand description

Denotes an floating-point type.

These include:

See also StdFloatingPoint.

§Safety

Bits must be a compatible type so that one may losslessly transmute between it and the implementing type.

All items must behave to the same specifications as the standard items.

Required Associated Constants§

Source

const DIGITS: u32

Source

const E: Self

Source

const EPSILON: Self

Source

const EULER_GAMMA: Self

Source

const FRAC_1_PI: Self

Source

const FRAC_1_SQRT_2: Self

Source

const FRAC_2_PI: Self

Source

const FRAC_2_SQRT_PI: Self

Source

const FRAC_PI_2: Self

Source

const FRAC_PI_3: Self

Source

const FRAC_PI_4: Self

Source

const FRAC_PI_6: Self

Source

const FRAC_PI_8: Self

Source

const GOLDEN_RATIO: Self

Source

const INFINITY: Self

Source

const LN_10: Self

Source

const LN_2: Self

Source

const LOG10_2: Self

Source

const LOG10_E: Self

Source

const LOG2_10: Self

Source

const LOG2_E: Self

Source

const MANTISSA_DIGITS: u32

Source

const MAX: Self

See f64::MAX.

Source

const MAX_10_EXP: i32

Source

const MAX_EXP: i32

Source

const MIN: Self

See f64::MIN.

Source

const MIN_10_EXP: i32

Source

const MIN_EXP: i32

Source

const MIN_POSITIVE: Self

Source

const NAN: Self

See f64::NAN.

Source

const NEG_INFINITY: Self

Source

const PI: Self

Source

const RADIX: u32

Source

const SQRT_2: Self

Source

const TAU: Self

Required Associated Types§

Source

type Bits: Unsigned

The scalar type that represents the bits of this type.

Required Methods§

Source

fn abs(self) -> Self

See f64::abs.

Source

fn clamp(self, min: Self, max: Self) -> Self

Source

fn classify(self) -> FpCategory

Source

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

Source

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

Source

fn is_finite(self) -> bool

Source

fn is_infinite(self) -> bool

Source

fn is_nan(self) -> bool

Source

fn is_normal(self) -> bool

Source

fn is_sign_negative(self) -> bool

Source

fn is_sign_positive(self) -> bool

Source

fn is_subnormal(self) -> bool

Source

fn max(self, rhs: Self) -> Self

See f64::max.

Source

fn midpoint(self, rhs: Self) -> Self

Source

fn min(self, rhs: Self) -> Self

See f64::min.

Source

fn next_down(self) -> Self

Source

fn next_up(self) -> Self

Source

fn recip(self) -> Self

Source

fn signum(self) -> Self

Source

fn to_bits(self) -> Self::Bits

Source

fn to_degrees(self) -> Self

Source

fn to_radians(self) -> Self

Source

fn total_cmp(&self, rhs: &Self) -> Ordering

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 FloatingPoint for f16

Available on crate feature f16 only.
Source§

const DIGITS: u32 = Self::DIGITS

Source§

const E: Self = ::core::f16::consts::E

Source§

const EPSILON: Self = Self::EPSILON

Source§

const EULER_GAMMA: Self = 0.577215664901532860606512090082402431042159335939923598805767

Source§

const FRAC_1_PI: Self = ::core::f16::consts::FRAC_1_PI

Source§

const FRAC_1_SQRT_2: Self = ::core::f16::consts::FRAC_1_SQRT_2

Source§

const FRAC_2_PI: Self = ::core::f16::consts::FRAC_2_PI

Source§

const FRAC_2_SQRT_PI: Self = ::core::f16::consts::FRAC_2_SQRT_PI

Source§

const FRAC_PI_2: Self = ::core::f16::consts::FRAC_PI_2

Source§

const FRAC_PI_3: Self = ::core::f16::consts::FRAC_PI_3

Source§

const FRAC_PI_4: Self = ::core::f16::consts::FRAC_PI_4

Source§

const FRAC_PI_6: Self = ::core::f16::consts::FRAC_PI_6

Source§

const FRAC_PI_8: Self = ::core::f16::consts::FRAC_PI_8

Source§

const GOLDEN_RATIO: Self = 1.618033988749894848204586834365638117720309179805762862135450

Source§

const INFINITY: Self = Self::EPSILON

Source§

const LN_10: Self = ::core::f16::consts::LN_10

Source§

const LN_2: Self = ::core::f16::consts::LN_2

Source§

const LOG10_2: Self = ::core::f16::consts::LOG10_2

Source§

const LOG10_E: Self = ::core::f16::consts::LOG10_E

Source§

const LOG2_10: Self = ::core::f16::consts::LOG2_10

Source§

const LOG2_E: Self = ::core::f16::consts::LOG2_E

Source§

const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS

Source§

const MAX: Self = Self::MAX

Source§

const MAX_10_EXP: i32 = Self::MAX_10_EXP

Source§

const MAX_EXP: i32 = Self::MAX_EXP

Source§

const MIN: Self = Self::MIN

Source§

const MIN_10_EXP: i32 = Self::MIN_10_EXP

Source§

const MIN_EXP: i32 = Self::MIN_EXP

Source§

const MIN_POSITIVE: Self = Self::MIN_POSITIVE

Source§

const NAN: Self = Self::NAN

Source§

const NEG_INFINITY: Self = Self::NEG_INFINITY

Source§

const PI: Self = ::core::f16::consts::PI

Source§

const RADIX: u32 = Self::RADIX

Source§

const SQRT_2: Self = ::core::f16::consts::SQRT_2

Source§

const TAU: Self = ::core::f16::consts::TAU

Source§

type Bits = u16

Source§

fn abs(self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn classify(self) -> FpCategory

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_normal(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_subnormal(self) -> bool

Source§

fn max(self, rhs: Self) -> Self

Source§

fn midpoint(self, rhs: Self) -> Self

Source§

fn min(self, rhs: Self) -> Self

Source§

fn next_down(self) -> Self

Source§

fn next_up(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn signum(self) -> Self

Source§

fn to_bits(self) -> Self::Bits

Source§

fn to_degrees(self) -> Self

Source§

fn to_radians(self) -> Self

Source§

fn total_cmp(&self, rhs: &Self) -> Ordering

Source§

impl FloatingPoint for f32

Source§

const DIGITS: u32 = Self::DIGITS

Source§

const E: Self = ::core::f32::consts::E

Source§

const EPSILON: Self = Self::EPSILON

Source§

const EULER_GAMMA: Self = 0.577215664901532860606512090082402431042159335939923598805767

Source§

const FRAC_1_PI: Self = ::core::f32::consts::FRAC_1_PI

Source§

const FRAC_1_SQRT_2: Self = ::core::f32::consts::FRAC_1_SQRT_2

Source§

const FRAC_2_PI: Self = ::core::f32::consts::FRAC_2_PI

Source§

const FRAC_2_SQRT_PI: Self = ::core::f32::consts::FRAC_2_SQRT_PI

Source§

const FRAC_PI_2: Self = ::core::f32::consts::FRAC_PI_2

Source§

const FRAC_PI_3: Self = ::core::f32::consts::FRAC_PI_3

Source§

const FRAC_PI_4: Self = ::core::f32::consts::FRAC_PI_4

Source§

const FRAC_PI_6: Self = ::core::f32::consts::FRAC_PI_6

Source§

const FRAC_PI_8: Self = ::core::f32::consts::FRAC_PI_8

Source§

const GOLDEN_RATIO: Self = 1.618033988749894848204586834365638117720309179805762862135450

Source§

const INFINITY: Self = Self::EPSILON

Source§

const LN_10: Self = ::core::f32::consts::LN_10

Source§

const LN_2: Self = ::core::f32::consts::LN_2

Source§

const LOG10_2: Self = ::core::f32::consts::LOG10_2

Source§

const LOG10_E: Self = ::core::f32::consts::LOG10_E

Source§

const LOG2_10: Self = ::core::f32::consts::LOG2_10

Source§

const LOG2_E: Self = ::core::f32::consts::LOG2_E

Source§

const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS

Source§

const MAX: Self = Self::MAX

Source§

const MAX_10_EXP: i32 = Self::MAX_10_EXP

Source§

const MAX_EXP: i32 = Self::MAX_EXP

Source§

const MIN: Self = Self::MIN

Source§

const MIN_10_EXP: i32 = Self::MIN_10_EXP

Source§

const MIN_EXP: i32 = Self::MIN_EXP

Source§

const MIN_POSITIVE: Self = Self::MIN_POSITIVE

Source§

const NAN: Self = Self::NAN

Source§

const NEG_INFINITY: Self = Self::NEG_INFINITY

Source§

const PI: Self = ::core::f32::consts::PI

Source§

const RADIX: u32 = Self::RADIX

Source§

const SQRT_2: Self = ::core::f32::consts::SQRT_2

Source§

const TAU: Self = ::core::f32::consts::TAU

Source§

type Bits = u32

Source§

fn abs(self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn classify(self) -> FpCategory

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_normal(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_subnormal(self) -> bool

Source§

fn max(self, rhs: Self) -> Self

Source§

fn midpoint(self, rhs: Self) -> Self

Source§

fn min(self, rhs: Self) -> Self

Source§

fn next_down(self) -> Self

Source§

fn next_up(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn signum(self) -> Self

Source§

fn to_bits(self) -> Self::Bits

Source§

fn to_degrees(self) -> Self

Source§

fn to_radians(self) -> Self

Source§

fn total_cmp(&self, rhs: &Self) -> Ordering

Source§

impl FloatingPoint for f64

Source§

const DIGITS: u32 = Self::DIGITS

Source§

const E: Self = ::core::f64::consts::E

Source§

const EPSILON: Self = Self::EPSILON

Source§

const EULER_GAMMA: Self = 0.577215664901532860606512090082402431042159335939923598805767

Source§

const FRAC_1_PI: Self = ::core::f64::consts::FRAC_1_PI

Source§

const FRAC_1_SQRT_2: Self = ::core::f64::consts::FRAC_1_SQRT_2

Source§

const FRAC_2_PI: Self = ::core::f64::consts::FRAC_2_PI

Source§

const FRAC_2_SQRT_PI: Self = ::core::f64::consts::FRAC_2_SQRT_PI

Source§

const FRAC_PI_2: Self = ::core::f64::consts::FRAC_PI_2

Source§

const FRAC_PI_3: Self = ::core::f64::consts::FRAC_PI_3

Source§

const FRAC_PI_4: Self = ::core::f64::consts::FRAC_PI_4

Source§

const FRAC_PI_6: Self = ::core::f64::consts::FRAC_PI_6

Source§

const FRAC_PI_8: Self = ::core::f64::consts::FRAC_PI_8

Source§

const GOLDEN_RATIO: Self = 1.618033988749894848204586834365638117720309179805762862135450

Source§

const INFINITY: Self = Self::EPSILON

Source§

const LN_10: Self = ::core::f64::consts::LN_10

Source§

const LN_2: Self = ::core::f64::consts::LN_2

Source§

const LOG10_2: Self = ::core::f64::consts::LOG10_2

Source§

const LOG10_E: Self = ::core::f64::consts::LOG10_E

Source§

const LOG2_10: Self = ::core::f64::consts::LOG2_10

Source§

const LOG2_E: Self = ::core::f64::consts::LOG2_E

Source§

const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS

Source§

const MAX: Self = Self::MAX

Source§

const MAX_10_EXP: i32 = Self::MAX_10_EXP

Source§

const MAX_EXP: i32 = Self::MAX_EXP

Source§

const MIN: Self = Self::MIN

Source§

const MIN_10_EXP: i32 = Self::MIN_10_EXP

Source§

const MIN_EXP: i32 = Self::MIN_EXP

Source§

const MIN_POSITIVE: Self = Self::MIN_POSITIVE

Source§

const NAN: Self = Self::NAN

Source§

const NEG_INFINITY: Self = Self::NEG_INFINITY

Source§

const PI: Self = ::core::f64::consts::PI

Source§

const RADIX: u32 = Self::RADIX

Source§

const SQRT_2: Self = ::core::f64::consts::SQRT_2

Source§

const TAU: Self = ::core::f64::consts::TAU

Source§

type Bits = u64

Source§

fn abs(self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn classify(self) -> FpCategory

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_normal(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_subnormal(self) -> bool

Source§

fn max(self, rhs: Self) -> Self

Source§

fn midpoint(self, rhs: Self) -> Self

Source§

fn min(self, rhs: Self) -> Self

Source§

fn next_down(self) -> Self

Source§

fn next_up(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn signum(self) -> Self

Source§

fn to_bits(self) -> Self::Bits

Source§

fn to_degrees(self) -> Self

Source§

fn to_radians(self) -> Self

Source§

fn total_cmp(&self, rhs: &Self) -> Ordering

Source§

impl FloatingPoint for f128

Available on crate feature f128 only.
Source§

const DIGITS: u32 = Self::DIGITS

Source§

const E: Self = ::core::f128::consts::E

Source§

const EPSILON: Self = Self::EPSILON

Source§

const EULER_GAMMA: Self = 0.577215664901532860606512090082402431042159335939923598805767

Source§

const FRAC_1_PI: Self = ::core::f128::consts::FRAC_1_PI

Source§

const FRAC_1_SQRT_2: Self = ::core::f128::consts::FRAC_1_SQRT_2

Source§

const FRAC_2_PI: Self = ::core::f128::consts::FRAC_2_PI

Source§

const FRAC_2_SQRT_PI: Self = ::core::f128::consts::FRAC_2_SQRT_PI

Source§

const FRAC_PI_2: Self = ::core::f128::consts::FRAC_PI_2

Source§

const FRAC_PI_3: Self = ::core::f128::consts::FRAC_PI_3

Source§

const FRAC_PI_4: Self = ::core::f128::consts::FRAC_PI_4

Source§

const FRAC_PI_6: Self = ::core::f128::consts::FRAC_PI_6

Source§

const FRAC_PI_8: Self = ::core::f128::consts::FRAC_PI_8

Source§

const GOLDEN_RATIO: Self = 1.618033988749894848204586834365638117720309179805762862135450

Source§

const INFINITY: Self = Self::EPSILON

Source§

const LN_10: Self = ::core::f128::consts::LN_10

Source§

const LN_2: Self = ::core::f128::consts::LN_2

Source§

const LOG10_2: Self = ::core::f128::consts::LOG10_2

Source§

const LOG10_E: Self = ::core::f128::consts::LOG10_E

Source§

const LOG2_10: Self = ::core::f128::consts::LOG2_10

Source§

const LOG2_E: Self = ::core::f128::consts::LOG2_E

Source§

const MANTISSA_DIGITS: u32 = Self::MANTISSA_DIGITS

Source§

const MAX: Self = Self::MAX

Source§

const MAX_10_EXP: i32 = Self::MAX_10_EXP

Source§

const MAX_EXP: i32 = Self::MAX_EXP

Source§

const MIN: Self = Self::MIN

Source§

const MIN_10_EXP: i32 = Self::MIN_10_EXP

Source§

const MIN_EXP: i32 = Self::MIN_EXP

Source§

const MIN_POSITIVE: Self = Self::MIN_POSITIVE

Source§

const NAN: Self = Self::NAN

Source§

const NEG_INFINITY: Self = Self::NEG_INFINITY

Source§

const PI: Self = ::core::f128::consts::PI

Source§

const RADIX: u32 = Self::RADIX

Source§

const SQRT_2: Self = ::core::f128::consts::SQRT_2

Source§

const TAU: Self = ::core::f128::consts::TAU

Source§

type Bits = u128

Source§

fn abs(self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn classify(self) -> FpCategory

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_normal(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

fn is_sign_positive(self) -> bool

Source§

fn is_subnormal(self) -> bool

Source§

fn max(self, rhs: Self) -> Self

Source§

fn midpoint(self, rhs: Self) -> Self

Source§

fn min(self, rhs: Self) -> Self

Source§

fn next_down(self) -> Self

Source§

fn next_up(self) -> Self

Source§

fn recip(self) -> Self

Source§

fn signum(self) -> Self

Source§

fn to_bits(self) -> Self::Bits

Source§

fn to_degrees(self) -> Self

Source§

fn to_radians(self) -> Self

Source§

fn total_cmp(&self, rhs: &Self) -> Ordering

Implementors§