Apply stability attributes to std::num::Float.
This commit is contained in:
parent
ae4762761c
commit
65922dd42d
|
@ -73,7 +73,7 @@ mod cmath {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable = "trait is unstable"]
|
#[stable]
|
||||||
impl Float for f32 {
|
impl Float for f32 {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn nan() -> f32 { num::Float::nan() }
|
fn nan() -> f32 { num::Float::nan() }
|
||||||
|
|
|
@ -81,7 +81,7 @@ mod cmath {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[unstable = "trait is unstable"]
|
#[stable]
|
||||||
impl Float for f64 {
|
impl Float for f64 {
|
||||||
// inlined methods from `num::Float`
|
// inlined methods from `num::Float`
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -37,6 +37,7 @@ use option::Option;
|
||||||
pub mod strconv;
|
pub mod strconv;
|
||||||
|
|
||||||
/// Mathematical operations on primitive floating point numbers.
|
/// Mathematical operations on primitive floating point numbers.
|
||||||
|
#[stable]
|
||||||
pub trait Float
|
pub trait Float
|
||||||
: Copy + Clone
|
: Copy + Clone
|
||||||
+ NumCast
|
+ NumCast
|
||||||
|
@ -92,57 +93,58 @@ pub trait Float
|
||||||
/// Returns the maximum base-10 exponent that this type can represent.
|
/// Returns the maximum base-10 exponent that this type can represent.
|
||||||
#[deprecated = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate"]
|
#[deprecated = "use `std::f32::MAX_10_EXP` or `std::f64::MAX_10_EXP` as appropriate"]
|
||||||
fn max_10_exp(unused_self: Option<Self>) -> int;
|
fn max_10_exp(unused_self: Option<Self>) -> int;
|
||||||
|
|
||||||
/// Returns the smallest finite value that this type can represent.
|
/// Returns the smallest finite value that this type can represent.
|
||||||
#[deprecated = "use `std::f32::MIN_VALUE` or `std::f64::MIN_VALUE` as appropriate"]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn min_value() -> Self;
|
fn min_value() -> Self;
|
||||||
/// Returns the smallest normalized positive number that this type can represent.
|
/// Returns the smallest normalized positive number that this type can represent.
|
||||||
#[deprecated = "use `std::f32::MIN_POS_VALUE` or `std::f64::MIN_POS_VALUE` as appropriate"]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn min_pos_value(unused_self: Option<Self>) -> Self;
|
fn min_pos_value(unused_self: Option<Self>) -> Self;
|
||||||
/// Returns the largest finite value that this type can represent.
|
/// Returns the largest finite value that this type can represent.
|
||||||
#[deprecated = "use `std::f32::MAX_VALUE` or `std::f64::MAX_VALUE` as appropriate"]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn max_value() -> Self;
|
fn max_value() -> Self;
|
||||||
|
|
||||||
/// Returns true if this value is NaN and false otherwise.
|
/// Returns true if this value is NaN and false otherwise.
|
||||||
#[stable]
|
#[unstable = "position is undecided"]
|
||||||
fn is_nan(self) -> bool;
|
fn is_nan(self) -> bool;
|
||||||
/// Returns true if this value is positive infinity or negative infinity and
|
/// Returns true if this value is positive infinity or negative infinity and
|
||||||
/// false otherwise.
|
/// false otherwise.
|
||||||
#[stable]
|
#[unstable = "position is undecided"]
|
||||||
fn is_infinite(self) -> bool;
|
fn is_infinite(self) -> bool;
|
||||||
/// Returns true if this number is neither infinite nor NaN.
|
/// Returns true if this number is neither infinite nor NaN.
|
||||||
#[stable]
|
#[unstable = "position is undecided"]
|
||||||
fn is_finite(self) -> bool;
|
fn is_finite(self) -> bool;
|
||||||
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
|
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
|
||||||
#[stable]
|
#[unstable = "position is undecided"]
|
||||||
fn is_normal(self) -> bool;
|
fn is_normal(self) -> bool;
|
||||||
/// Returns the category that this number falls into.
|
/// Returns the category that this number falls into.
|
||||||
#[stable]
|
#[stable]
|
||||||
fn classify(self) -> FpCategory;
|
fn classify(self) -> FpCategory;
|
||||||
|
|
||||||
/// Returns the mantissa, exponent and sign as integers, respectively.
|
/// Returns the mantissa, exponent and sign as integers, respectively.
|
||||||
#[stable]
|
#[unstable = "signature is undecided"]
|
||||||
fn integer_decode(self) -> (u64, i16, i8);
|
fn integer_decode(self) -> (u64, i16, i8);
|
||||||
|
|
||||||
/// Return the largest integer less than or equal to a number.
|
/// Return the largest integer less than or equal to a number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn floor(self) -> Self;
|
fn floor(self) -> Self;
|
||||||
/// Return the smallest integer greater than or equal to a number.
|
/// Return the smallest integer greater than or equal to a number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn ceil(self) -> Self;
|
fn ceil(self) -> Self;
|
||||||
/// Return the nearest integer to a number. Round half-way cases away from
|
/// Return the nearest integer to a number. Round half-way cases away from
|
||||||
/// `0.0`.
|
/// `0.0`.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn round(self) -> Self;
|
fn round(self) -> Self;
|
||||||
/// Return the integer part of a number.
|
/// Return the integer part of a number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn trunc(self) -> Self;
|
fn trunc(self) -> Self;
|
||||||
/// Return the fractional part of a number.
|
/// Return the fractional part of a number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn fract(self) -> Self;
|
fn fract(self) -> Self;
|
||||||
|
|
||||||
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
|
||||||
/// number is `Float::nan()`.
|
/// number is `Float::nan()`.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn abs(self) -> Self;
|
fn abs(self) -> Self;
|
||||||
/// Returns a number that represents the sign of `self`.
|
/// Returns a number that represents the sign of `self`.
|
||||||
///
|
///
|
||||||
|
@ -163,58 +165,59 @@ pub trait Float
|
||||||
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
|
||||||
/// error. This produces a more accurate result with better performance than
|
/// error. This produces a more accurate result with better performance than
|
||||||
/// a separate multiplication operation followed by an add.
|
/// a separate multiplication operation followed by an add.
|
||||||
#[stable]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn mul_add(self, a: Self, b: Self) -> Self;
|
fn mul_add(self, a: Self, b: Self) -> Self;
|
||||||
/// Take the reciprocal (inverse) of a number, `1/x`.
|
/// Take the reciprocal (inverse) of a number, `1/x`.
|
||||||
#[stable]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn recip(self) -> Self;
|
fn recip(self) -> Self;
|
||||||
|
|
||||||
/// Raise a number to an integer power.
|
/// Raise a number to an integer power.
|
||||||
///
|
///
|
||||||
/// Using this function is generally faster than using `powf`
|
/// Using this function is generally faster than using `powf`
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn powi(self, n: i32) -> Self;
|
fn powi(self, n: i32) -> Self;
|
||||||
/// Raise a number to a floating point power.
|
/// Raise a number to a floating point power.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn powf(self, n: Self) -> Self;
|
fn powf(self, n: Self) -> Self;
|
||||||
|
|
||||||
/// Take the square root of a number.
|
/// Take the square root of a number.
|
||||||
///
|
///
|
||||||
/// Returns NaN if `self` is a negative number.
|
/// Returns NaN if `self` is a negative number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn sqrt(self) -> Self;
|
fn sqrt(self) -> Self;
|
||||||
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
||||||
#[unstable = "TODO"]
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn rsqrt(self) -> Self;
|
fn rsqrt(self) -> Self;
|
||||||
|
|
||||||
/// Returns `e^(self)`, (the exponential function).
|
/// Returns `e^(self)`, (the exponential function).
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn exp(self) -> Self;
|
fn exp(self) -> Self;
|
||||||
/// Returns 2 raised to the power of the number, `2^(self)`.
|
/// Returns 2 raised to the power of the number, `2^(self)`.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn exp2(self) -> Self;
|
fn exp2(self) -> Self;
|
||||||
/// Returns the natural logarithm of the number.
|
/// Returns the natural logarithm of the number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn ln(self) -> Self;
|
fn ln(self) -> Self;
|
||||||
/// Returns the logarithm of the number with respect to an arbitrary base.
|
/// Returns the logarithm of the number with respect to an arbitrary base.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn log(self, base: Self) -> Self;
|
fn log(self, base: Self) -> Self;
|
||||||
/// Returns the base 2 logarithm of the number.
|
/// Returns the base 2 logarithm of the number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn log2(self) -> Self;
|
fn log2(self) -> Self;
|
||||||
/// Returns the base 10 logarithm of the number.
|
/// Returns the base 10 logarithm of the number.
|
||||||
#[unstable = "TODO"]
|
#[stable]
|
||||||
fn log10(self) -> Self;
|
fn log10(self) -> Self;
|
||||||
|
|
||||||
/// Convert radians to degrees.
|
/// Convert radians to degrees.
|
||||||
#[unstable = "TODO"]
|
#[unstable = "desirability is unclear"]
|
||||||
fn to_degrees(self) -> Self;
|
fn to_degrees(self) -> Self;
|
||||||
/// Convert degrees to radians.
|
/// Convert degrees to radians.
|
||||||
#[unstable = "TODO"]
|
#[unstable = "desirability is unclear"]
|
||||||
fn to_radians(self) -> Self;
|
fn to_radians(self) -> Self;
|
||||||
|
|
||||||
/// Constructs a floating point number created by multiplying `x` by 2
|
/// Constructs a floating point number created by multiplying `x` by 2
|
||||||
/// raised to the power of `exp`.
|
/// raised to the power of `exp`.
|
||||||
|
#[unstable = "pending integer conventions"]
|
||||||
fn ldexp(x: Self, exp: int) -> Self;
|
fn ldexp(x: Self, exp: int) -> Self;
|
||||||
/// Breaks the number into a normalized fraction and a base-2 exponent,
|
/// Breaks the number into a normalized fraction and a base-2 exponent,
|
||||||
/// satisfying:
|
/// satisfying:
|
||||||
|
@ -222,71 +225,94 @@ pub trait Float
|
||||||
/// * `self = x * pow(2, exp)`
|
/// * `self = x * pow(2, exp)`
|
||||||
///
|
///
|
||||||
/// * `0.5 <= abs(x) < 1.0`
|
/// * `0.5 <= abs(x) < 1.0`
|
||||||
|
#[unstable = "pending integer conventions"]
|
||||||
fn frexp(self) -> (Self, int);
|
fn frexp(self) -> (Self, int);
|
||||||
|
|
||||||
/// Returns the next representable floating-point value in the direction of
|
/// Returns the next representable floating-point value in the direction of
|
||||||
/// `other`.
|
/// `other`.
|
||||||
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn next_after(self, other: Self) -> Self;
|
fn next_after(self, other: Self) -> Self;
|
||||||
|
|
||||||
/// Returns the maximum of the two numbers.
|
/// Returns the maximum of the two numbers.
|
||||||
|
#[stable]
|
||||||
fn max(self, other: Self) -> Self;
|
fn max(self, other: Self) -> Self;
|
||||||
/// Returns the minimum of the two numbers.
|
/// Returns the minimum of the two numbers.
|
||||||
|
#[stable]
|
||||||
fn min(self, other: Self) -> Self;
|
fn min(self, other: Self) -> Self;
|
||||||
|
|
||||||
/// The positive difference of two numbers. Returns `0.0` if the number is
|
/// The positive difference of two numbers. Returns `0.0` if the number is
|
||||||
/// less than or equal to `other`, otherwise the difference between`self`
|
/// less than or equal to `other`, otherwise the difference between`self`
|
||||||
/// and `other` is returned.
|
/// and `other` is returned.
|
||||||
|
#[unstable = "may be renamed"]
|
||||||
fn abs_sub(self, other: Self) -> Self;
|
fn abs_sub(self, other: Self) -> Self;
|
||||||
|
|
||||||
/// Take the cubic root of a number.
|
/// Take the cubic root of a number.
|
||||||
|
#[unstable = "may be renamed"]
|
||||||
fn cbrt(self) -> Self;
|
fn cbrt(self) -> Self;
|
||||||
/// Calculate the length of the hypotenuse of a right-angle triangle given
|
/// Calculate the length of the hypotenuse of a right-angle triangle given
|
||||||
/// legs of length `x` and `y`.
|
/// legs of length `x` and `y`.
|
||||||
|
#[unstable = "unsure about its place in the world"]
|
||||||
fn hypot(self, other: Self) -> Self;
|
fn hypot(self, other: Self) -> Self;
|
||||||
|
|
||||||
/// Computes the sine of a number (in radians).
|
/// Computes the sine of a number (in radians).
|
||||||
|
#[stable]
|
||||||
fn sin(self) -> Self;
|
fn sin(self) -> Self;
|
||||||
/// Computes the cosine of a number (in radians).
|
/// Computes the cosine of a number (in radians).
|
||||||
|
#[stable]
|
||||||
fn cos(self) -> Self;
|
fn cos(self) -> Self;
|
||||||
/// Computes the tangent of a number (in radians).
|
/// Computes the tangent of a number (in radians).
|
||||||
|
#[stable]
|
||||||
fn tan(self) -> Self;
|
fn tan(self) -> Self;
|
||||||
|
|
||||||
/// Computes the arcsine of a number. Return value is in radians in
|
/// 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
|
/// the range [-pi/2, pi/2] or NaN if the number is outside the range
|
||||||
/// [-1, 1].
|
/// [-1, 1].
|
||||||
|
#[stable]
|
||||||
fn asin(self) -> Self;
|
fn asin(self) -> Self;
|
||||||
/// Computes the arccosine of a number. Return value is in radians in
|
/// 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
|
/// the range [0, pi] or NaN if the number is outside the range
|
||||||
/// [-1, 1].
|
/// [-1, 1].
|
||||||
|
#[stable]
|
||||||
fn acos(self) -> Self;
|
fn acos(self) -> Self;
|
||||||
/// Computes the arctangent of a number. Return value is in radians in the
|
/// Computes the arctangent of a number. Return value is in radians in the
|
||||||
/// range [-pi/2, pi/2];
|
/// range [-pi/2, pi/2];
|
||||||
|
#[stable]
|
||||||
fn atan(self) -> Self;
|
fn atan(self) -> Self;
|
||||||
/// Computes the four quadrant arctangent of a number, `y`, and another
|
/// Computes the four quadrant arctangent of a number, `y`, and another
|
||||||
/// number `x`. Return value is in radians in the range [-pi, pi].
|
/// number `x`. Return value is in radians in the range [-pi, pi].
|
||||||
|
#[stable]
|
||||||
fn atan2(self, other: Self) -> Self;
|
fn atan2(self, other: Self) -> Self;
|
||||||
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
|
/// Simultaneously computes the sine and cosine of the number, `x`. Returns
|
||||||
/// `(sin(x), cos(x))`.
|
/// `(sin(x), cos(x))`.
|
||||||
|
#[stable]
|
||||||
fn sin_cos(self) -> (Self, Self);
|
fn sin_cos(self) -> (Self, Self);
|
||||||
|
|
||||||
/// Returns the exponential of the number, minus 1, in a way that is
|
/// Returns the exponential of the number, minus 1, in a way that is
|
||||||
/// accurate even if the number is close to zero.
|
/// accurate even if the number is close to zero.
|
||||||
|
#[unstable = "may be renamed"]
|
||||||
fn exp_m1(self) -> Self;
|
fn exp_m1(self) -> Self;
|
||||||
/// Returns the natural logarithm of the number plus 1 (`ln(1+n)`) more
|
/// Returns the natural logarithm of the number plus 1 (`ln(1+n)`) more
|
||||||
/// accurately than if the operations were performed separately.
|
/// accurately than if the operations were performed separately.
|
||||||
|
#[unstable = "may be renamed"]
|
||||||
fn ln_1p(self) -> Self;
|
fn ln_1p(self) -> Self;
|
||||||
|
|
||||||
/// Hyperbolic sine function.
|
/// Hyperbolic sine function.
|
||||||
|
#[stable]
|
||||||
fn sinh(self) -> Self;
|
fn sinh(self) -> Self;
|
||||||
/// Hyperbolic cosine function.
|
/// Hyperbolic cosine function.
|
||||||
|
#[stable]
|
||||||
fn cosh(self) -> Self;
|
fn cosh(self) -> Self;
|
||||||
/// Hyperbolic tangent function.
|
/// Hyperbolic tangent function.
|
||||||
|
#[stable]
|
||||||
fn tanh(self) -> Self;
|
fn tanh(self) -> Self;
|
||||||
/// Inverse hyperbolic sine function.
|
/// Inverse hyperbolic sine function.
|
||||||
|
#[stable]
|
||||||
fn asinh(self) -> Self;
|
fn asinh(self) -> Self;
|
||||||
/// Inverse hyperbolic cosine function.
|
/// Inverse hyperbolic cosine function.
|
||||||
|
#[stable]
|
||||||
fn acosh(self) -> Self;
|
fn acosh(self) -> Self;
|
||||||
/// Inverse hyperbolic tangent function.
|
/// Inverse hyperbolic tangent function.
|
||||||
|
#[stable]
|
||||||
fn atanh(self) -> Self;
|
fn atanh(self) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue