mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Simplify the configuration for no-panic
Currently, attributes for `no-panic` are gated behind both the `test` config and `assert_no_panic`, because `no-panic` is a dev dependency (so only available with test configuration). However, we only emit `assert_no_panic` when the test config is also set anyway, so there isn't any need to gate on both. Replace gates on `all(test, assert_no_panic)` with only `assert_no_panic`. This is simpler, and also has the benefit that attempting to check for panics without `--test` errors.
This commit is contained in:
@@ -59,7 +59,7 @@ fn r(z: f64) -> f64 {
|
||||
/// Computes the inverse cosine (arc cosine) of the input value.
|
||||
/// Arguments must be in the range -1 to 1.
|
||||
/// Returns values in radians, in the range of 0 to pi.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn acos(x: f64) -> f64 {
|
||||
let x1p_120f = f64::from_bits(0x3870000000000000); // 0x1p-120 === 2 ^ -120
|
||||
let z: f64;
|
||||
|
||||
@@ -33,7 +33,7 @@ fn r(z: f32) -> f32 {
|
||||
/// Computes the inverse cosine (arc cosine) of the input value.
|
||||
/// Arguments must be in the range -1 to 1.
|
||||
/// Returns values in radians, in the range of 0 to pi.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn acosf(x: f32) -> f32 {
|
||||
let x1p_120 = f32::from_bits(0x03800000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// Calculates the inverse hyperbolic cosine of `x`.
|
||||
/// Is defined as `log(x + sqrt(x*x-1))`.
|
||||
/// `x` must be a number greater than or equal to 1.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn acosh(x: f64) -> f64 {
|
||||
let u = x.to_bits();
|
||||
let e = ((u >> 52) as usize) & 0x7ff;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/// Calculates the inverse hyperbolic cosine of `x`.
|
||||
/// Is defined as `log(x + sqrt(x*x-1))`.
|
||||
/// `x` must be a number greater than or equal to 1.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn acoshf(x: f32) -> f32 {
|
||||
let u = x.to_bits();
|
||||
let a = u & 0x7fffffff;
|
||||
|
||||
@@ -66,7 +66,7 @@ fn comp_r(z: f64) -> f64 {
|
||||
/// Computes the inverse sine (arc sine) of the argument `x`.
|
||||
/// Arguments to asin must be in the range -1 to 1.
|
||||
/// Returns values in radians, in the range of -pi/2 to pi/2.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn asin(mut x: f64) -> f64 {
|
||||
let z: f64;
|
||||
let r: f64;
|
||||
|
||||
@@ -35,7 +35,7 @@ fn r(z: f32) -> f32 {
|
||||
/// Computes the inverse sine (arc sine) of the argument `x`.
|
||||
/// Arguments to asin must be in the range -1 to 1.
|
||||
/// Returns values in radians, in the range of -pi/2 to pi/2.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn asinf(mut x: f32) -> f32 {
|
||||
let x1p_120 = f64::from_bits(0x3870000000000000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
///
|
||||
/// Calculates the inverse hyperbolic sine of `x`.
|
||||
/// Is defined as `sgn(x)*log(|x|+sqrt(x*x+1))`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn asinh(mut x: f64) -> f64 {
|
||||
let mut u = x.to_bits();
|
||||
let e = ((u >> 52) as usize) & 0x7ff;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
///
|
||||
/// Calculates the inverse hyperbolic sine of `x`.
|
||||
/// Is defined as `sgn(x)*log(|x|+sqrt(x*x+1))`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn asinhf(mut x: f32) -> f32 {
|
||||
let u = x.to_bits();
|
||||
let i = u & 0x7fffffff;
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
///
|
||||
/// Computes the inverse tangent (arc tangent) of the input value.
|
||||
/// Returns a value in radians, in the range of -pi/2 to pi/2.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atan(x: f64) -> f64 {
|
||||
let mut x = x;
|
||||
let mut ix = (x.to_bits() >> 32) as u32;
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
/// Computes the inverse tangent (arc tangent) of `y/x`.
|
||||
/// Produces the correct result even for angles near pi/2 or -pi/2 (that is, when `x` is near 0).
|
||||
/// Returns a value in radians, in the range of -pi to pi.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atan2(y: f64, x: f64) -> f64 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
/// Computes the inverse tangent (arc tangent) of `y/x`.
|
||||
/// Produces the correct result even for angles near pi/2 or -pi/2 (that is, when `x` is near 0).
|
||||
/// Returns a value in radians, in the range of -pi to pi.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atan2f(y: f32, x: f32) -> f32 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
///
|
||||
/// Computes the inverse tangent (arc tangent) of the input value.
|
||||
/// Returns a value in radians, in the range of -pi/2 to pi/2.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atanf(mut x: f32) -> f32 {
|
||||
let x1p_120 = f32::from_bits(0x03800000); // 0x1p-120 === 2 ^ (-120)
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
///
|
||||
/// Calculates the inverse hyperbolic tangent of `x`.
|
||||
/// Is defined as `log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atanh(x: f64) -> f64 {
|
||||
let u = x.to_bits();
|
||||
let e = ((u >> 52) as usize) & 0x7ff;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
///
|
||||
/// Calculates the inverse hyperbolic tangent of `x`.
|
||||
/// Is defined as `log((1+x)/(1-x))/2 = log1p(2x/(1-x))/2`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn atanhf(mut x: f32) -> f32 {
|
||||
let mut u = x.to_bits();
|
||||
let sign = (u >> 31) != 0;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use super::support::{FpResult, Round, cold_path};
|
||||
|
||||
/// Compute the cube root of the argument.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn cbrt(x: f64) -> f64 {
|
||||
cbrt_round(x, Round::Nearest).val
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
/// Cube root (f32)
|
||||
///
|
||||
/// Computes the cube root of the argument.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn cbrtf(x: f32) -> f32 {
|
||||
let x1p24 = f32::from_bits(0x4b800000); // 0x1p24f === 2 ^ 24
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
///
|
||||
/// Finds the nearest integer greater than or equal to `x`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ceilf16(x: f16) -> f16 {
|
||||
super::generic::ceil(x)
|
||||
}
|
||||
@@ -10,7 +10,7 @@ pub fn ceilf16(x: f16) -> f16 {
|
||||
/// Ceil (f32)
|
||||
///
|
||||
/// Finds the nearest integer greater than or equal to `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ceilf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: ceilf,
|
||||
@@ -24,7 +24,7 @@ pub fn ceilf(x: f32) -> f32 {
|
||||
/// Ceil (f64)
|
||||
///
|
||||
/// Finds the nearest integer greater than or equal to `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ceil(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: ceil,
|
||||
@@ -40,7 +40,7 @@ pub fn ceil(x: f64) -> f64 {
|
||||
///
|
||||
/// Finds the nearest integer greater than or equal to `x`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ceilf128(x: f128) -> f128 {
|
||||
super::generic::ceil(x)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/// Constructs a number with the magnitude (absolute value) of its
|
||||
/// first argument, `x`, and the sign of its second argument, `y`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn copysignf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::copysign(x, y)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ pub fn copysignf16(x: f16, y: f16) -> f16 {
|
||||
///
|
||||
/// Constructs a number with the magnitude (absolute value) of its
|
||||
/// first argument, `x`, and the sign of its second argument, `y`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn copysignf(x: f32, y: f32) -> f32 {
|
||||
super::generic::copysign(x, y)
|
||||
}
|
||||
@@ -21,7 +21,7 @@ pub fn copysignf(x: f32, y: f32) -> f32 {
|
||||
///
|
||||
/// Constructs a number with the magnitude (absolute value) of its
|
||||
/// first argument, `x`, and the sign of its second argument, `y`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn copysign(x: f64, y: f64) -> f64 {
|
||||
super::generic::copysign(x, y)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ pub fn copysign(x: f64, y: f64) -> f64 {
|
||||
/// Constructs a number with the magnitude (absolute value) of its
|
||||
/// first argument, `x`, and the sign of its second argument, `y`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn copysignf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::copysign(x, y)
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
/// The cosine of `x` (f64).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn cos(x: f64) -> f64 {
|
||||
let ix = (f64::to_bits(x) >> 32) as u32 & 0x7fffffff;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// The cosine of `x` (f32).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn cosf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/// Computes the hyperbolic cosine of the argument x.
|
||||
/// Is defined as `(exp(x) + exp(-x))/2`
|
||||
/// Angles are specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn cosh(mut x: f64) -> f64 {
|
||||
/* |x| */
|
||||
let mut ix = x.to_bits();
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/// Computes the hyperbolic cosine of the argument x.
|
||||
/// Is defined as `(exp(x) + exp(-x))/2`
|
||||
/// Angles are specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn coshf(mut x: f32) -> f32 {
|
||||
let x1p120 = f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ fn erfc2(ix: u32, mut x: f64) -> f64 {
|
||||
/// Calculates an approximation to the “error function”, which estimates
|
||||
/// the probability that an observation will fall within x standard
|
||||
/// deviations of the mean (assuming a normal distribution).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn erf(x: f64) -> f64 {
|
||||
let r: f64;
|
||||
let s: f64;
|
||||
|
||||
@@ -130,7 +130,7 @@ fn erfc2(mut ix: u32, mut x: f32) -> f32 {
|
||||
/// Calculates an approximation to the “error function”, which estimates
|
||||
/// the probability that an observation will fall within x standard
|
||||
/// deviations of the mean (assuming a normal distribution).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn erff(x: f32) -> f32 {
|
||||
let r: f32;
|
||||
let s: f32;
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
///
|
||||
/// Calculate the exponential of `x`, that is, *e* raised to the power `x`
|
||||
/// (where *e* is the base of the natural system of logarithms, approximately 2.71828).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp(mut x: f64) -> f64 {
|
||||
let x1p1023 = f64::from_bits(0x7fe0000000000000); // 0x1p1023 === 2 ^ 1023
|
||||
let x1p_149 = f64::from_bits(0x36a0000000000000); // 0x1p-149 === 2 ^ -149
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
];
|
||||
|
||||
/// Calculates 10 raised to the power of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp10(x: f64) -> f64 {
|
||||
let (mut y, n) = modf(x);
|
||||
let u: u64 = n.to_bits();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
];
|
||||
|
||||
/// Calculates 10 raised to the power of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp10f(x: f32) -> f32 {
|
||||
let (mut y, n) = modff(x);
|
||||
let u = n.to_bits();
|
||||
|
||||
@@ -322,7 +322,7 @@
|
||||
/// Exponential, base 2 (f64)
|
||||
///
|
||||
/// Calculate `2^x`, that is, 2 raised to the power `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp2(mut x: f64) -> f64 {
|
||||
let redux = f64::from_bits(0x4338000000000000) / TBLSIZE as f64;
|
||||
let p1 = f64::from_bits(0x3fe62e42fefa39ef);
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
/// Exponential, base 2 (f32)
|
||||
///
|
||||
/// Calculate `2^x`, that is, 2 raised to the power `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn exp2f(mut x: f32) -> f32 {
|
||||
let redux = f32::from_bits(0x4b400000) / TBLSIZE as f32;
|
||||
let p1 = f32::from_bits(0x3f317218);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
///
|
||||
/// Calculate the exponential of `x`, that is, *e* raised to the power `x`
|
||||
/// (where *e* is the base of the natural system of logarithms, approximately 2.71828).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn expf(mut x: f32) -> f32 {
|
||||
let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
|
||||
let x1p_126 = f32::from_bits(0x800000); // 0x1p-126f === 2 ^ -126 /*original 0x1p-149f ??????????? */
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
/// system of logarithms, approximately 2.71828).
|
||||
/// The result is accurate even for small values of `x`,
|
||||
/// where using `exp(x)-1` would lose many significant digits.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn expm1(mut x: f64) -> f64 {
|
||||
let hi: f64;
|
||||
let lo: f64;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
/// system of logarithms, approximately 2.71828).
|
||||
/// The result is accurate even for small values of `x`,
|
||||
/// where using `exp(x)-1` would lose many significant digits.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn expm1f(mut x: f32) -> f32 {
|
||||
let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 127
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::{combine_words, exp};
|
||||
|
||||
/* exp(x)/2 for x >= log(DBL_MAX), slightly better than 0.5*exp(x/2)*exp(x/2) */
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn expo2(x: f64) -> f64 {
|
||||
/* k is such that k*ln2 has minimal relative error and x - kln2 > log(DBL_MIN) */
|
||||
const K: i32 = 2043;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/// Calculates the absolute value (magnitude) of the argument `x`,
|
||||
/// by direct manipulation of the bit representation of `x`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fabsf16(x: f16) -> f16 {
|
||||
super::generic::fabs(x)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ pub fn fabsf16(x: f16) -> f16 {
|
||||
///
|
||||
/// Calculates the absolute value (magnitude) of the argument `x`,
|
||||
/// by direct manipulation of the bit representation of `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fabsf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: fabsf,
|
||||
@@ -27,7 +27,7 @@ pub fn fabsf(x: f32) -> f32 {
|
||||
///
|
||||
/// Calculates the absolute value (magnitude) of the argument `x`,
|
||||
/// by direct manipulation of the bit representation of `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fabs(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: fabs,
|
||||
@@ -43,7 +43,7 @@ pub fn fabs(x: f64) -> f64 {
|
||||
/// Calculates the absolute value (magnitude) of the argument `x`,
|
||||
/// by direct manipulation of the bit representation of `x`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fabsf128(x: f128) -> f128 {
|
||||
super::generic::fabs(x)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
///
|
||||
/// A range error may occur.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fdimf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fdim(x, y)
|
||||
}
|
||||
@@ -20,7 +20,7 @@ pub fn fdimf16(x: f16, y: f16) -> f16 {
|
||||
/// * NAN if either argument is NAN.
|
||||
///
|
||||
/// A range error may occur.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fdimf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fdim(x, y)
|
||||
}
|
||||
@@ -33,7 +33,7 @@ pub fn fdimf(x: f32, y: f32) -> f32 {
|
||||
/// * NAN if either argument is NAN.
|
||||
///
|
||||
/// A range error may occur.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fdim(x: f64, y: f64) -> f64 {
|
||||
super::generic::fdim(x, y)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ pub fn fdim(x: f64, y: f64) -> f64 {
|
||||
///
|
||||
/// A range error may occur.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fdimf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fdim(x, y)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
///
|
||||
/// Finds the nearest integer less than or equal to `x`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn floorf16(x: f16) -> f16 {
|
||||
return super::generic::floor(x);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ pub fn floorf16(x: f16) -> f16 {
|
||||
/// Floor (f64)
|
||||
///
|
||||
/// Finds the nearest integer less than or equal to `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn floor(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: floor,
|
||||
@@ -25,7 +25,7 @@ pub fn floor(x: f64) -> f64 {
|
||||
/// Floor (f32)
|
||||
///
|
||||
/// Finds the nearest integer less than or equal to `x`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn floorf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: floorf,
|
||||
@@ -40,7 +40,7 @@ pub fn floorf(x: f32) -> f32 {
|
||||
///
|
||||
/// Finds the nearest integer less than or equal to `x`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn floorf128(x: f128) -> f128 {
|
||||
return super::generic::floor(x);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// Placeholder so we can have `fmaf16` in the `Float` trait.
|
||||
#[allow(unused)]
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn fmaf16(_x: f16, _y: f16, _z: f16) -> f16 {
|
||||
unimplemented!()
|
||||
}
|
||||
@@ -15,7 +15,7 @@ pub(crate) fn fmaf16(_x: f16, _y: f16, _z: f16) -> f16 {
|
||||
/// Floating multiply add (f32)
|
||||
///
|
||||
/// Computes `(x*y)+z`, rounded as one ternary operation (i.e. calculated with infinite precision).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaf(x: f32, y: f32, z: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: fmaf,
|
||||
@@ -32,7 +32,7 @@ pub fn fmaf(x: f32, y: f32, z: f32) -> f32 {
|
||||
/// Fused multiply add (f64)
|
||||
///
|
||||
/// Computes `(x*y)+z`, rounded as one ternary operation (i.e. calculated with infinite precision).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: fma,
|
||||
@@ -50,7 +50,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
||||
///
|
||||
/// Computes `(x*y)+z`, rounded as one ternary operation (i.e. calculated with infinite precision).
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaf128(x: f128, y: f128, z: f128) -> f128 {
|
||||
generic::fma_round(x, y, z, Round::Nearest).val
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/// This coincides with IEEE 754-2011 `minNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fmin(x, y)
|
||||
}
|
||||
@@ -12,7 +12,7 @@ pub fn fminf16(x: f16, y: f16) -> f16 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2011 `minNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fmin(x, y)
|
||||
}
|
||||
@@ -21,7 +21,7 @@ pub fn fminf(x: f32, y: f32) -> f32 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2011 `minNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmin(x: f64, y: f64) -> f64 {
|
||||
super::generic::fmin(x, y)
|
||||
}
|
||||
@@ -31,7 +31,7 @@ pub fn fmin(x: f64, y: f64) -> f64 {
|
||||
/// This coincides with IEEE 754-2011 `minNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fmin(x, y)
|
||||
}
|
||||
@@ -41,7 +41,7 @@ pub fn fminf128(x: f128, y: f128) -> f128 {
|
||||
/// This coincides with IEEE 754-2011 `maxNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaxf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fmax(x, y)
|
||||
}
|
||||
@@ -50,7 +50,7 @@ pub fn fmaxf16(x: f16, y: f16) -> f16 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2011 `maxNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaxf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fmax(x, y)
|
||||
}
|
||||
@@ -59,7 +59,7 @@ pub fn fmaxf(x: f32, y: f32) -> f32 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2011 `maxNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmax(x: f64, y: f64) -> f64 {
|
||||
super::generic::fmax(x, y)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ pub fn fmax(x: f64, y: f64) -> f64 {
|
||||
/// This coincides with IEEE 754-2011 `maxNum`. The result disregards signed zero (meaning if
|
||||
/// the inputs are -0.0 and +0.0, either may be returned).
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaxf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fmax(x, y)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimum`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimumf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fminimum(x, y)
|
||||
}
|
||||
@@ -10,7 +10,7 @@ pub fn fminimumf16(x: f16, y: f16) -> f16 {
|
||||
/// Return the lesser of two arguments or, if either argument is NaN, the other argument.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimum`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimum(x: f64, y: f64) -> f64 {
|
||||
super::generic::fminimum(x, y)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ pub fn fminimum(x: f64, y: f64) -> f64 {
|
||||
/// Return the lesser of two arguments or, if either argument is NaN, the other argument.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimum`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimumf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fminimum(x, y)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ pub fn fminimumf(x: f32, y: f32) -> f32 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimum`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimumf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fminimum(x, y)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ pub fn fminimumf128(x: f128, y: f128) -> f128 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximum`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximumf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fmaximum(x, y)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ pub fn fmaximumf16(x: f16, y: f16) -> f16 {
|
||||
/// Return the greater of two arguments or, if either argument is NaN, the other argument.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximum`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximumf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fmaximum(x, y)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ pub fn fmaximumf(x: f32, y: f32) -> f32 {
|
||||
/// Return the greater of two arguments or, if either argument is NaN, the other argument.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximum`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximum(x: f64, y: f64) -> f64 {
|
||||
super::generic::fmaximum(x, y)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ pub fn fmaximum(x: f64, y: f64) -> f64 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximum`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximumf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fmaximum(x, y)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimum_numf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fminimum_num(x, y)
|
||||
}
|
||||
@@ -10,7 +10,7 @@ pub fn fminimum_numf16(x: f16, y: f16) -> f16 {
|
||||
/// Return the lesser of two arguments or, if either argument is NaN, NaN.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimum_numf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fminimum_num(x, y)
|
||||
}
|
||||
@@ -18,7 +18,7 @@ pub fn fminimum_numf(x: f32, y: f32) -> f32 {
|
||||
/// Return the lesser of two arguments or, if either argument is NaN, NaN.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimum_num(x: f64, y: f64) -> f64 {
|
||||
super::generic::fminimum_num(x, y)
|
||||
}
|
||||
@@ -27,7 +27,7 @@ pub fn fminimum_num(x: f64, y: f64) -> f64 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `minimumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fminimum_numf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fminimum_num(x, y)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ pub fn fminimum_numf128(x: f128, y: f128) -> f128 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximum_numf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fmaximum_num(x, y)
|
||||
}
|
||||
@@ -44,7 +44,7 @@ pub fn fmaximum_numf16(x: f16, y: f16) -> f16 {
|
||||
/// Return the greater of two arguments or, if either argument is NaN, NaN.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximum_numf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fmaximum_num(x, y)
|
||||
}
|
||||
@@ -52,7 +52,7 @@ pub fn fmaximum_numf(x: f32, y: f32) -> f32 {
|
||||
/// Return the greater of two arguments or, if either argument is NaN, NaN.
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximum_num(x: f64, y: f64) -> f64 {
|
||||
super::generic::fmaximum_num(x, y)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ pub fn fmaximum_num(x: f64, y: f64) -> f64 {
|
||||
///
|
||||
/// This coincides with IEEE 754-2019 `maximumNumber`. The result orders -0.0 < 0.0.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmaximum_numf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fmaximum_num(x, y)
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmodf16(x: f16, y: f16) -> f16 {
|
||||
super::generic::fmod(x, y)
|
||||
}
|
||||
|
||||
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmodf(x: f32, y: f32) -> f32 {
|
||||
super::generic::fmod(x, y)
|
||||
}
|
||||
|
||||
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmod(x: f64, y: f64) -> f64 {
|
||||
super::generic::fmod(x, y)
|
||||
}
|
||||
|
||||
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn fmodf128(x: f128, y: f128) -> f128 {
|
||||
super::generic::fmod(x, y)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn frexp(x: f64) -> (f64, i32) {
|
||||
let mut y = x.to_bits();
|
||||
let ee = ((y >> 52) & 0x7ff) as i32;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn frexpf(x: f32) -> (f32, i32) {
|
||||
let mut y = x.to_bits();
|
||||
let ee: i32 = ((y >> 23) & 0xff) as i32;
|
||||
|
||||
@@ -17,7 +17,7 @@ fn sq(x: f64) -> (f64, f64) {
|
||||
(hi, lo)
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn hypot(mut x: f64, mut y: f64) -> f64 {
|
||||
let x1p700 = f64::from_bits(0x6bb0000000000000); // 0x1p700 === 2 ^ 700
|
||||
let x1p_700 = f64::from_bits(0x1430000000000000); // 0x1p-700 === 2 ^ -700
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use super::sqrtf;
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn hypotf(mut x: f32, mut y: f32) -> f32 {
|
||||
let x1p90 = f32::from_bits(0x6c800000); // 0x1p90f === 2 ^ 90
|
||||
let x1p_90 = f32::from_bits(0x12800000); // 0x1p-90f === 2 ^ -90
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const FP_ILOGBNAN: i32 = -1 - 0x7fffffff;
|
||||
const FP_ILOGB0: i32 = FP_ILOGBNAN;
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ilogb(x: f64) -> i32 {
|
||||
let mut i: u64 = x.to_bits();
|
||||
let e = ((i >> 52) & 0x7ff) as i32;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const FP_ILOGBNAN: i32 = -1 - 0x7fffffff;
|
||||
const FP_ILOGB0: i32 = FP_ILOGBNAN;
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ilogbf(x: f32) -> i32 {
|
||||
let mut i = x.to_bits();
|
||||
let e = ((i >> 23) & 0xff) as i32;
|
||||
|
||||
@@ -110,7 +110,7 @@ fn common(ix: u32, x: f64, y0: bool) -> f64 {
|
||||
const S04: f64 = 1.16614003333790000205e-09; /* 0x3E1408BC, 0xF4745D8F */
|
||||
|
||||
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn j0(mut x: f64) -> f64 {
|
||||
let z: f64;
|
||||
let r: f64;
|
||||
@@ -165,7 +165,7 @@ pub fn j0(mut x: f64) -> f64 {
|
||||
const V04: f64 = 4.41110311332675467403e-10; /* 0x3DFE5018, 0x3BD6D9EF */
|
||||
|
||||
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn y0(x: f64) -> f64 {
|
||||
let z: f64;
|
||||
let u: f64;
|
||||
|
||||
@@ -63,7 +63,7 @@ fn common(ix: u32, x: f32, y0: bool) -> f32 {
|
||||
const S04: f32 = 1.1661400734e-09; /* 0x30a045e8 */
|
||||
|
||||
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn j0f(mut x: f32) -> f32 {
|
||||
let z: f32;
|
||||
let r: f32;
|
||||
@@ -110,7 +110,7 @@ pub fn j0f(mut x: f32) -> f32 {
|
||||
const V04: f32 = 4.4111031494e-10; /* 0x2ff280c2 */
|
||||
|
||||
/// Zeroth order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn y0f(x: f32) -> f32 {
|
||||
let z: f32;
|
||||
let u: f32;
|
||||
|
||||
@@ -114,7 +114,7 @@ fn common(ix: u32, x: f64, y1: bool, sign: bool) -> f64 {
|
||||
const S05: f64 = 1.23542274426137913908e-11; /* 0x3DAB2ACF, 0xCFB97ED8 */
|
||||
|
||||
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn j1(x: f64) -> f64 {
|
||||
let mut z: f64;
|
||||
let r: f64;
|
||||
@@ -161,7 +161,7 @@ pub fn j1(x: f64) -> f64 {
|
||||
];
|
||||
|
||||
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn y1(x: f64) -> f64 {
|
||||
let z: f64;
|
||||
let u: f64;
|
||||
|
||||
@@ -64,7 +64,7 @@ fn common(ix: u32, x: f32, y1: bool, sign: bool) -> f32 {
|
||||
const S05: f32 = 1.2354227016e-11; /* 0x2d59567e */
|
||||
|
||||
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn j1f(x: f32) -> f32 {
|
||||
let mut z: f32;
|
||||
let r: f32;
|
||||
@@ -110,7 +110,7 @@ pub fn j1f(x: f32) -> f32 {
|
||||
];
|
||||
|
||||
/// First order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn y1f(x: f32) -> f32 {
|
||||
let z: f32;
|
||||
let u: f32;
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
const INVSQRTPI: f64 = 5.64189583547756279280e-01; /* 0x3FE20DD7, 0x50429B6D */
|
||||
|
||||
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn jn(n: i32, mut x: f64) -> f64 {
|
||||
let mut ix: u32;
|
||||
let lx: u32;
|
||||
@@ -249,7 +249,7 @@ pub fn jn(n: i32, mut x: f64) -> f64 {
|
||||
}
|
||||
|
||||
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn yn(n: i32, x: f64) -> f64 {
|
||||
let mut ix: u32;
|
||||
let lx: u32;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
use super::{fabsf, j0f, j1f, logf, y0f, y1f};
|
||||
|
||||
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the first kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn jnf(n: i32, mut x: f32) -> f32 {
|
||||
let mut ix: u32;
|
||||
let mut nm1: i32;
|
||||
@@ -192,7 +192,7 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
|
||||
}
|
||||
|
||||
/// Integer order of the [Bessel function](https://en.wikipedia.org/wiki/Bessel_function) of the second kind (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ynf(n: i32, x: f32) -> f32 {
|
||||
let mut ix: u32;
|
||||
let mut ib: u32;
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
// expression for cos(). Retention happens in all cases tested
|
||||
// under FreeBSD, so don't pessimize things by forcibly clipping
|
||||
// any extra precision in w.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_cos(x: f64, y: f64) -> f64 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
const C2: f64 = -0.00138867637746099294692; /* -0x16c087e80f1e27.0p-62 */
|
||||
const C3: f64 = 0.0000243904487962774090654; /* 0x199342e0ee5069.0p-68 */
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_cosf(x: f64) -> f32 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
const K: i32 = 2043;
|
||||
|
||||
/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_expo2(x: f64) -> f64 {
|
||||
let k_ln2 = f64::from_bits(0x40962066151add8b);
|
||||
/* note that k is odd and scale*scale overflows */
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
const K: i32 = 235;
|
||||
|
||||
/* expf(x)/2 for x >= log(FLT_MAX), slightly better than 0.5f*expf(x/2)*expf(x/2) */
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_expo2f(x: f32) -> f32 {
|
||||
let k_ln2 = f32::from_bits(0x4322e3bc);
|
||||
/* note that k is odd and scale*scale overflows */
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
// r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
|
||||
// then 3 2
|
||||
// sin(x) = x + (S1*x + (x *(r-y/2)+y))
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_sin(x: f64, y: f64, iy: i32) -> f64 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
const S3: f64 = -0.000198393348360966317347; /* -0x1a00f9e2cae774.0p-65 */
|
||||
const S4: f64 = 0.0000027183114939898219064; /* 0x16cd878c3b46a7.0p-71 */
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_sinf(x: f64) -> f32 {
|
||||
let z = x * x;
|
||||
let w = z * z;
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
const PIO4: f64 = 7.85398163397448278999e-01; /* 3FE921FB, 54442D18 */
|
||||
const PIO4_LO: f64 = 3.06161699786838301793e-17; /* 3C81A626, 33145C07 */
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_tan(mut x: f64, mut y: f64, odd: i32) -> f64 {
|
||||
let hx = (f64::to_bits(x) >> 32) as u32;
|
||||
let big = (hx & 0x7fffffff) >= 0x3FE59428; /* |x| >= 0.6744 */
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
0.00946564784943673166728, /* 0x1362b9bf971bcd.0p-59 */
|
||||
];
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn k_tanf(x: f64, odd: bool) -> f32 {
|
||||
let z = x * x;
|
||||
/*
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ldexpf16(x: f16, n: i32) -> f16 {
|
||||
super::scalbnf16(x, n)
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ldexpf(x: f32, n: i32) -> f32 {
|
||||
super::scalbnf(x, n)
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ldexp(x: f64, n: i32) -> f64 {
|
||||
super::scalbn(x, n)
|
||||
}
|
||||
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn ldexpf128(x: f128, n: i32) -> f128 {
|
||||
super::scalbnf128(x, n)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/// The natural logarithm of the
|
||||
/// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn lgamma(x: f64) -> f64 {
|
||||
lgamma_r(x).0
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ fn sin_pi(mut x: f64) -> f64 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn lgamma_r(mut x: f64) -> (f64, i32) {
|
||||
let u: u64 = x.to_bits();
|
||||
let mut t: f64;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/// The natural logarithm of the
|
||||
/// [Gamma function](https://en.wikipedia.org/wiki/Gamma_function) (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn lgammaf(x: f32) -> f32 {
|
||||
lgammaf_r(x).0
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ fn sin_pi(mut x: f32) -> f32 {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn lgammaf_r(mut x: f32) -> (f32, i32) {
|
||||
let u = x.to_bits();
|
||||
let mut t: f32;
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
/// The natural logarithm of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
/// The base 10 logarithm of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log10(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
/// The base 10 logarithm of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log10f(mut x: f32) -> f32 {
|
||||
let x1p25f = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
/// The natural logarithm of 1+`x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log1p(x: f64) -> f64 {
|
||||
let mut ui: u64 = x.to_bits();
|
||||
let hfsq: f64;
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
/// The natural logarithm of 1+`x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log1pf(x: f32) -> f32 {
|
||||
let mut ui: u32 = x.to_bits();
|
||||
let hfsq: f32;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
const LG7: f64 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
|
||||
|
||||
/// The base 2 logarithm of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log2(mut x: f64) -> f64 {
|
||||
let x1p54 = f64::from_bits(0x4350000000000000); // 0x1p54 === 2 ^ 54
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
/// The base 2 logarithm of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn log2f(mut x: f32) -> f32 {
|
||||
let x1p25f = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
const LG4: f32 = 0.24279078841; /* 0xf89e26.0p-26 */
|
||||
|
||||
/// The natural logarithm of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn logf(mut x: f32) -> f32 {
|
||||
let x1p25 = f32::from_bits(0x4c000000); // 0x1p25f === 2 ^ 25
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn modf(x: f64) -> (f64, f64) {
|
||||
let rv2: f64;
|
||||
let mut u = x.to_bits();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn modff(x: f32) -> (f32, f32) {
|
||||
let rv2: f32;
|
||||
let mut u: u32 = x.to_bits();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn nextafter(x: f64, y: f64) -> f64 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn nextafterf(x: f32, y: f32) -> f32 {
|
||||
if x.is_nan() || y.is_nan() {
|
||||
return x + y;
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
const IVLN2_L: f64 = 1.92596299112661746887e-08; /* 0x3e54ae0b_f85ddf44 =1/ln2 tail*/
|
||||
|
||||
/// Returns `x` to the power of `y` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn pow(x: f64, y: f64) -> f64 {
|
||||
let t1: f64;
|
||||
let t2: f64;
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
const IVLN2_L: f32 = 7.0526075433e-06;
|
||||
|
||||
/// Returns `x` to the power of `y` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn powf(x: f32, y: f32) -> f32 {
|
||||
let mut z: f32;
|
||||
let mut ax: f32;
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
// use rem_pio2_large() for large x
|
||||
//
|
||||
// caller must handle the case when reduction is not needed: |x| ~<= pi/4 */
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn rem_pio2(x: f64) -> (i32, f64, f64) {
|
||||
let x1p24 = f64::from_bits(0x4170000000000000);
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@
|
||||
/// skip the part of the product that are known to be a huge integer (
|
||||
/// more accurately, = 0 mod 8 ). Thus the number of operations are
|
||||
/// independent of the exponent of the input.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn rem_pio2_large(x: &[f64], y: &mut [f64], e0: i32, prec: usize) -> i32 {
|
||||
// FIXME(rust-lang/rust#144518): Inline assembly would cause `no_panic` to fail
|
||||
// on the callers of this function. As a workaround, avoid inlining `floor` here
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
///
|
||||
/// use double precision for everything except passing x
|
||||
/// use __rem_pio2_large() for large x
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub(crate) fn rem_pio2f(x: f32) -> (i32, f64) {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn remainder(x: f64, y: f64) -> f64 {
|
||||
let (result, _) = super::remquo(x, y);
|
||||
result
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn remainderf(x: f32, y: f32) -> f32 {
|
||||
let (result, _) = super::remquof(x, y);
|
||||
result
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn remquo(mut x: f64, mut y: f64) -> (f64, i32) {
|
||||
let ux: u64 = x.to_bits();
|
||||
let mut uy: u64 = y.to_bits();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn remquof(mut x: f32, mut y: f32) -> (f32, i32) {
|
||||
let ux: u32 = x.to_bits();
|
||||
let mut uy: u32 = y.to_bits();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn rintf16(x: f16) -> f16 {
|
||||
select_implementation! {
|
||||
name: rintf16,
|
||||
@@ -14,7 +14,7 @@ pub fn rintf16(x: f16) -> f16 {
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn rintf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: rintf,
|
||||
@@ -29,7 +29,7 @@ pub fn rintf(x: f32) -> f32 {
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn rint(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: rint,
|
||||
@@ -45,7 +45,7 @@ pub fn rint(x: f64) -> f64 {
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn rintf128(x: f128) -> f128 {
|
||||
super::generic::rint_round(x, Round::Nearest).val
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/// Round `x` to the nearest integer, breaking ties away from zero.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundf16(x: f16) -> f16 {
|
||||
super::generic::round(x)
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties away from zero.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundf(x: f32) -> f32 {
|
||||
super::generic::round(x)
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties away from zero.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn round(x: f64) -> f64 {
|
||||
super::generic::round(x)
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties away from zero.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundf128(x: f128) -> f128 {
|
||||
super::generic::round(x)
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@
|
||||
/// Round `x` to the nearest integer, breaking ties toward even. This is IEEE 754
|
||||
/// `roundToIntegralTiesToEven`.
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundevenf16(x: f16) -> f16 {
|
||||
roundeven_impl(x)
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even. This is IEEE 754
|
||||
/// `roundToIntegralTiesToEven`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundevenf(x: f32) -> f32 {
|
||||
roundeven_impl(x)
|
||||
}
|
||||
|
||||
/// Round `x` to the nearest integer, breaking ties toward even. This is IEEE 754
|
||||
/// `roundToIntegralTiesToEven`.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundeven(x: f64) -> f64 {
|
||||
roundeven_impl(x)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ pub fn roundeven(x: f64) -> f64 {
|
||||
/// Round `x` to the nearest integer, breaking ties toward even. This is IEEE 754
|
||||
/// `roundToIntegralTiesToEven`.
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn roundevenf128(x: f128) -> f128 {
|
||||
roundeven_impl(x)
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn scalbnf16(x: f16, n: i32) -> f16 {
|
||||
super::generic::scalbn(x, n)
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn scalbnf(x: f32, n: i32) -> f32 {
|
||||
super::generic::scalbn(x, n)
|
||||
}
|
||||
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn scalbn(x: f64, n: i32) -> f64 {
|
||||
super::generic::scalbn(x, n)
|
||||
}
|
||||
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn scalbnf128(x: f128, n: i32) -> f128 {
|
||||
super::generic::scalbn(x, n)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
/// The sine of `x` (f64).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sin(x: f64) -> f64 {
|
||||
let x1p120 = f64::from_bits(0x4770000000000000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
/// Both the sine and cosine of `x` (f64).
|
||||
///
|
||||
/// `x` is specified in radians and the return value is (sin(x), cos(x)).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sincos(x: f64) -> (f64, f64) {
|
||||
let s: f64;
|
||||
let c: f64;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/// Both the sine and cosine of `x` (f32).
|
||||
///
|
||||
/// `x` is specified in radians and the return value is (sin(x), cos(x)).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sincosf(x: f32) -> (f32, f32) {
|
||||
let s: f32;
|
||||
let c: f32;
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// The sine of `x` (f32).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sinf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
//
|
||||
|
||||
/// The hyperbolic sine of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sinh(x: f64) -> f64 {
|
||||
// union {double f; uint64_t i;} u = {.f = x};
|
||||
// uint32_t w;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::{expm1f, k_expo2f};
|
||||
|
||||
/// The hyperbolic sine of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sinhf(x: f32) -> f32 {
|
||||
let mut h = 0.5f32;
|
||||
let mut ix = x.to_bits();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/// The square root of `x` (f16).
|
||||
#[cfg(f16_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sqrtf16(x: f16) -> f16 {
|
||||
select_implementation! {
|
||||
name: sqrtf16,
|
||||
@@ -12,7 +12,7 @@ pub fn sqrtf16(x: f16) -> f16 {
|
||||
}
|
||||
|
||||
/// The square root of `x` (f32).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sqrtf(x: f32) -> f32 {
|
||||
select_implementation! {
|
||||
name: sqrtf,
|
||||
@@ -28,7 +28,7 @@ pub fn sqrtf(x: f32) -> f32 {
|
||||
}
|
||||
|
||||
/// The square root of `x` (f64).
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sqrt(x: f64) -> f64 {
|
||||
select_implementation! {
|
||||
name: sqrt,
|
||||
@@ -45,7 +45,7 @@ pub fn sqrt(x: f64) -> f64 {
|
||||
|
||||
/// The square root of `x` (f128).
|
||||
#[cfg(f128_enabled)]
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn sqrtf128(x: f128) -> f128 {
|
||||
return super::generic::sqrt(x);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
/// The tangent of `x` (f64).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn tan(x: f64) -> f64 {
|
||||
let x1p120 = f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
/// The tangent of `x` (f32).
|
||||
///
|
||||
/// `x` is specified in radians.
|
||||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
|
||||
#[cfg_attr(assert_no_panic, no_panic::no_panic)]
|
||||
pub fn tanf(x: f32) -> f32 {
|
||||
let x64 = x as f64;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user