Trait std::num::FloatStable
[-]
[+]
[src]
pub trait Float: Copy + Clone + NumCast + PartialOrd + PartialEq + Neg<Output=Self> + 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 zero() -> Self;
fn neg_zero() -> Self;
fn one() -> Self;
fn mantissa_digits(unused_self: Option<Self>) -> usize;
fn digits(unused_self: Option<Self>) -> usize;
fn epsilon() -> Self;
fn min_exp(unused_self: Option<Self>) -> isize;
fn max_exp(unused_self: Option<Self>) -> isize;
fn min_10_exp(unused_self: Option<Self>) -> isize;
fn max_10_exp(unused_self: Option<Self>) -> isize;
fn min_value() -> Self;
fn min_pos_value(unused_self: Option<Self>) -> 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 integer_decode(self) -> (u64, i16, i8);
fn floor(self) -> Self;
fn ceil(self) -> Self;
fn round(self) -> Self;
fn trunc(self) -> Self;
fn fract(self) -> Self;
fn abs(self) -> Self;
fn signum(self) -> Self;
fn is_positive(self) -> bool;
fn is_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 rsqrt(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 to_degrees(self) -> Self;
fn to_radians(self) -> Self;
fn ldexp(x: Self, exp: isize) -> Self;
fn frexp(self) -> (Self, isize);
fn next_after(self, other: 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;
}Mathematical operations on primitive floating point 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 zero() -> Self
Returns the 0 value.
fn neg_zero() -> Self
Returns -0.0.
fn one() -> Self
Returns the 1 value.
fn mantissa_digits(unused_self: Option<Self>) -> usize
Returns the number of binary digits of mantissa that this type supports.
fn digits(unused_self: Option<Self>) -> usize
Returns the number of base-10 digits of precision that this type supports.
fn epsilon() -> Self
Returns the difference between 1.0 and the smallest representable number larger than 1.0.
fn min_exp(unused_self: Option<Self>) -> isize
Returns the minimum binary exponent that this type can represent.
fn max_exp(unused_self: Option<Self>) -> isize
Returns the maximum binary exponent that this type can represent.
fn min_10_exp(unused_self: Option<Self>) -> isize
Returns the minimum base-10 exponent that this type can represent.
fn max_10_exp(unused_self: Option<Self>) -> isize
Returns the maximum base-10 exponent that this type can represent.
fn min_value() -> Self
Returns the smallest finite value that this type can represent.
fn min_pos_value(unused_self: Option<Self>) -> Self
Returns the smallest normalized positive number that this type can represent.
fn max_value() -> Self
Returns the largest finite value that this type can represent.
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 this number is neither zero, infinite, denormal, or NaN.
fn classify(self) -> FpCategory
Returns the category that this number falls into.
fn integer_decode(self) -> (u64, i16, i8)
Returns the mantissa, exponent and sign as integers, respectively.
fn floor(self) -> Self
Return the largest integer less than or equal to a number.
fn ceil(self) -> Self
Return the smallest integer greater than or equal to a number.
fn round(self) -> Self
Return 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
Return the fractional part of a number.
fn abs(self) -> Self
Computes the absolute value of self. Returns Float::nan() if the
number is Float::nan().
fn signum(self) -> Self
Returns a number that represents the sign of self.
1.0if the number is positive,+0.0orFloat::infinity()-1.0if the number is negative,-0.0orFloat::neg_infinity()Float::nan()if the number isFloat::nan()
fn is_positive(self) -> bool
Returns true if self is positive, including +0.0 and
Float::infinity().
fn is_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.
Using this function is generally faster than using powf
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 rsqrt(self) -> Self
Take the reciprocal (inverse) square root of a number, 1/sqrt(x).
fn exp(self) -> Self
Returns e^(self), (the exponential function).
fn exp2(self) -> Self
Returns 2 raised to the power of the number, 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 to_degrees(self) -> Self
Convert radians to degrees.
fn to_radians(self) -> Self
Convert degrees to radians.
fn ldexp(x: Self, exp: isize) -> Self
Constructs a floating point number created by multiplying x by 2
raised to the power of exp.
fn frexp(self) -> (Self, isize)
Breaks the number into a normalized fraction and a base-2 exponent, satisfying:
self = x * pow(2, exp)0.5 <= abs(x) < 1.0
fn next_after(self, other: Self) -> Self
Returns the next representable floating-point value in the direction of
other.
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. Returns 0.0 if the number is
less than or equal to other, otherwise the difference betweenself
and other is returned.
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 a number, y, and another
number x. Return value is in radians in the range [-pi, pi].
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 the exponential of the number, minus 1, in a way that is accurate even if the number is close to zero.
fn ln_1p(self) -> Self
Returns the natural logarithm of the number plus 1 (ln(1+n)) 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.