Skip to main content

Float

Trait Float 

Source
pub trait Float:
    Copy
    + Default
    + PartialEq
    + PartialOrd
    + Debug
    + Display
    + LowerExp
    + Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + Rem<Output = Self>
    + Neg<Output = Self>
    + AddAssign
    + SubAssign
    + MulAssign
    + DivAssign
    + Sum
    + Product
    + Send
    + Sync
    + 'static
    + Sealed {
    const ZERO: Self;
    const ONE: Self;
    const TWO: Self;
    const HALF: Self;
    const PI: Self;
    const INFINITY: Self;
    const NAN: Self;
    const EPSILON: Self;
    const MIN_POSITIVE: Self;
    const MAX: Self;
    const MANTISSA_DIGITS: u32;
Show 19 methods // Required methods fn from_f64(x: f64) -> Self; fn to_f64(self) -> f64; fn abs(self) -> Self; fn sqrt(self) -> Self; fn hypot(self, other: Self) -> Self; fn atan2(self, other: Self) -> Self; fn sin_cos(self) -> (Self, Self); fn exp(self) -> Self; fn ln(self) -> Self; fn ln_1p(self) -> Self; fn powi(self, n: i32) -> Self; fn mul_add(self, a: Self, b: Self) -> Self; fn copysign(self, sign: Self) -> Self; fn max(self, other: Self) -> Self; fn min(self, other: Self) -> Self; fn is_finite(self) -> bool; fn is_infinite(self) -> bool; fn is_nan(self) -> bool; fn is_sign_negative(self) -> bool;
}
Expand description

f32 or f64: the type of the parts of a Complex, and of the real numbers a matrix of either gives, such as its norms and singular values. The methods are those of the two types, for code generic over both. The trait is sealed.

Required Associated Constants§

Source

const ZERO: Self

Source

const ONE: Self

Source

const TWO: Self

Source

const HALF: Self

1/2.

Source

const PI: Self

π.

Source

const INFINITY: Self

Infinity.

Source

const NAN: Self

Not a number.

Source

const EPSILON: Self

The difference between 1 and the next larger float.

Source

const MIN_POSITIVE: Self

The smallest positive normal float.

Source

const MAX: Self

The largest finite float.

Source

const MANTISSA_DIGITS: u32

The number of significant bits, the hidden one included.

Required Methods§

Source

fn from_f64(x: f64) -> Self

The nearest float to x.

Source

fn to_f64(self) -> f64

The value as an f64, exactly.

Source

fn abs(self) -> Self

The absolute value.

Source

fn sqrt(self) -> Self

The square root.

Source

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

√(self² + other²) without an overflow or underflow in the squares.

Source

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

The angle of the point (other, self), in [-π, π].

Source

fn sin_cos(self) -> (Self, Self)

The sine and the cosine.

Source

fn exp(self) -> Self

e^self.

Source

fn ln(self) -> Self

The natural logarithm.

Source

fn ln_1p(self) -> Self

ln(1 + self), accurate near zero.

Source

fn powi(self, n: i32) -> Self

self to the integer power n.

Source

fn mul_add(self, a: Self, b: Self) -> Self

self · a + b with one rounding.

Source

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

The absolute value of self with the sign of sign.

Source

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

The larger of the two, ignoring a NaN.

Source

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

The smaller of the two, ignoring a NaN.

Source

fn is_finite(self) -> bool

Whether it is neither infinite nor NaN.

Source

fn is_infinite(self) -> bool

Whether it is infinite.

Source

fn is_nan(self) -> bool

Whether it is NaN.

Source

fn is_sign_negative(self) -> bool

Whether its sign bit is set, as for -0.0.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Float for f32

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

const TWO: Self = 2.0

Source§

const HALF: Self = 0.5

Source§

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

Source§

const INFINITY: Self = f32::INFINITY

Source§

const NAN: Self = f32::NAN

Source§

const EPSILON: Self = f32::EPSILON

Source§

const MIN_POSITIVE: Self = f32::MIN_POSITIVE

Source§

const MAX: Self = f32::MAX

Source§

const MANTISSA_DIGITS: u32 = f32::MANTISSA_DIGITS

Source§

fn from_f64(x: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

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

Source§

fn sin_cos(self) -> (Self, Self)

Source§

fn exp(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn ln_1p(self) -> Self

Source§

fn powi(self, n: i32) -> Self

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Source§

impl Float for f64

Source§

const ZERO: Self = 0.0

Source§

const ONE: Self = 1.0

Source§

const TWO: Self = 2.0

Source§

const HALF: Self = 0.5

Source§

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

Source§

const INFINITY: Self = f64::INFINITY

Source§

const NAN: Self = f64::NAN

Source§

const EPSILON: Self = f64::EPSILON

Source§

const MIN_POSITIVE: Self = f64::MIN_POSITIVE

Source§

const MAX: Self = f64::MAX

Source§

const MANTISSA_DIGITS: u32 = f64::MANTISSA_DIGITS

Source§

fn from_f64(x: f64) -> Self

Source§

fn to_f64(self) -> f64

Source§

fn abs(self) -> Self

Source§

fn sqrt(self) -> Self

Source§

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

Source§

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

Source§

fn sin_cos(self) -> (Self, Self)

Source§

fn exp(self) -> Self

Source§

fn ln(self) -> Self

Source§

fn ln_1p(self) -> Self

Source§

fn powi(self, n: i32) -> Self

Source§

fn mul_add(self, a: Self, b: Self) -> Self

Source§

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

Source§

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

Source§

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

Source§

fn is_finite(self) -> bool

Source§

fn is_infinite(self) -> bool

Source§

fn is_nan(self) -> bool

Source§

fn is_sign_negative(self) -> bool

Implementors§