Trait num_traits::Float [] [src]

pub trait Float: Copy + Clone + PartialOrd + PartialEq + Zero + One + Signed + Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + Rem<Output=Self> {
    fn nan() -> Self;
    fn infinity() -> Self;
    fn neg_infinity() -> Self;
    fn neg_zero() -> Self;
    fn min_value() -> Self;
    fn min_positive_value() -> Self;
    fn max_value() -> Self;
    fn is_nan(self) -> bool;
    fn is_infinite(self) -> bool;
    fn is_finite(self) -> bool;
    fn is_normal(self) -> bool;
    fn classify(self) -> FpCategory;
    fn floor(self) -> Self;
    fn ceil(self) -> Self;
    fn round(self) -> Self;
    fn trunc(self) -> Self;
    fn fract(self) -> Self;
    fn is_sign_positive(self) -> bool;
    fn is_sign_negative(self) -> bool;
    fn mul_add(self, a: Self, b: Self) -> Self;
    fn recip(self) -> Self;
    fn powi(self, n: i32) -> Self;
    fn powf(self, n: Self) -> Self;
    fn sqrt(self) -> Self;
    fn exp(self) -> Self;
    fn exp2(self) -> Self;
    fn ln(self) -> Self;
    fn log(self, base: Self) -> Self;
    fn log2(self) -> Self;
    fn log10(self) -> Self;
    fn max(self, other: Self) -> Self;
    fn min(self, other: Self) -> Self;
    fn abs_sub(self, other: Self) -> Self;
    fn cbrt(self) -> Self;
    fn hypot(self, other: Self) -> Self;
    fn sin(self) -> Self;
    fn cos(self) -> Self;
    fn tan(self) -> Self;
    fn asin(self) -> Self;
    fn acos(self) -> Self;
    fn atan(self) -> Self;
    fn atan2(self, other: Self) -> Self;
    fn sin_cos(self) -> (Self, Self);
    fn exp_m1(self) -> Self;
    fn ln_1p(self) -> Self;
    fn sinh(self) -> Self;
    fn cosh(self) -> Self;
    fn tanh(self) -> Self;
    fn asinh(self) -> Self;
    fn acosh(self) -> Self;
    fn atanh(self) -> Self;
}

Float numbers.

Required Methods

fn nan() -> Self

Returns the NaN value.

fn infinity() -> Self

Returns the infinite value.

fn neg_infinity() -> Self

Returns the negative infinite value.

fn neg_zero() -> Self

Returns -0.0.

fn min_value() -> Self

Returns the smallest value that can be represented by this numeric type.

fn min_positive_value() -> Self

Returns the smallest positive, normalized value that this type can represent.

fn max_value() -> Self

Returns the largest value that can be represented by this numeric type.

fn is_nan(self) -> bool

Returns true if this value is NaN and false otherwise.

fn is_infinite(self) -> bool

Returns true if this value is positive infinity or negative infinity and false otherwise.

fn is_finite(self) -> bool

Returns true if this number is neither infinite nor NaN.

fn is_normal(self) -> bool

Returns true if the number is neither zero, infinite, subnormal, or NaN.

fn classify(self) -> FpCategory

Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.

fn floor(self) -> Self

Returns the largest integer less than or equal to a number.

fn ceil(self) -> Self

Returns the smallest integer greater than or equal to a number.

fn round(self) -> Self

Returns the nearest integer to a number. Round half-way cases away from 0.0.

fn trunc(self) -> Self

Return the integer part of a number.

fn fract(self) -> Self

Returns the fractional part of a number.

fn is_sign_positive(self) -> bool

Returns true if self is positive, including +0.0 and Float::infinity().

fn is_sign_negative(self) -> bool

Returns true if self is negative, including -0.0 and Float::neg_infinity().

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

Fused multiply-add. Computes (self * a) + b with only one rounding error. This produces a more accurate result with better performance than a separate multiplication operation followed by an add.

fn recip(self) -> Self

Take the reciprocal (inverse) of a number, 1/x.

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

Raise a number to an integer power.

fn powf(self, n: Self) -> Self

Raise a number to a floating point power.

fn sqrt(self) -> Self

Take the square root of a number. Returns NaN if self is a negative number.

fn exp(self) -> Self

Returns e^(self), (the exponential function).

fn exp2(self) -> Self

Returns 2^(self).

fn ln(self) -> Self

Returns the natural logarithm of the number.

fn log(self, base: Self) -> Self

Returns the logarithm of the number with respect to an arbitrary base.

fn log2(self) -> Self

Returns the base 2 logarithm of the number.

fn log10(self) -> Self

Returns the base 10 logarithm of the number.

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

Returns the maximum of the two numbers.

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

Returns the minimum of the two numbers.

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

The positive difference of two numbers.

  • If self <= other: 0.0
  • Else: self - other

fn cbrt(self) -> Self

Take the cubic root of a number.

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

Calculate the length of the hypotenuse of a right-angle triangle given legs of length x and y.

fn sin(self) -> Self

Computes the sine of a number (in radians).

fn cos(self) -> Self

Computes the cosine of a number (in radians).

fn tan(self) -> Self

Computes the tangent of a number (in radians).

fn asin(self) -> Self

Computes the arcsine of a number. Return value is in radians in the range [-pi/2, pi/2] or NaN if the number is outside the range [-1, 1].

fn acos(self) -> Self

Computes the arccosine of a number. Return value is in radians in the range [0, pi] or NaN if the number is outside the range [-1, 1].

fn atan(self) -> Self

Computes the arctangent of a number. Return value is in radians in the range [-pi/2, pi/2].

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

Computes the four quadrant arctangent of self (y) and other (x).

  • x = 0, y = 0: 0
  • x >= 0: arctan(y/x) -> [-pi/2, pi/2]
  • y >= 0: arctan(y/x) + pi -> (pi/2, pi]
  • y < 0: arctan(y/x) - pi -> (-pi, -pi/2)

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

Simultaneously computes the sine and cosine of the number, x. Returns (sin(x), cos(x)).

fn exp_m1(self) -> Self

Returns e^(self) - 1 in a way that is accurate even if the number is close to zero.

fn ln_1p(self) -> Self

Returns ln(1+n) (natural logarithm) more accurately than if the operations were performed separately.

fn sinh(self) -> Self

Hyperbolic sine function.

fn cosh(self) -> Self

Hyperbolic cosine function.

fn tanh(self) -> Self

Hyperbolic tangent function.

fn asinh(self) -> Self

Inverse hyperbolic sine function.

fn acosh(self) -> Self

Inverse hyperbolic cosine function.

fn atanh(self) -> Self

Inverse hyperbolic tangent function.

Implementors