Merge pull request rust-lang/libm#371 from tgross35/clippy-fixes
Clippy fixes
This commit is contained in:
commit
2012164901
23 changed files with 34 additions and 34 deletions
|
|
@ -120,7 +120,6 @@ jobs:
|
|||
run: ./ci/download-musl.sh
|
||||
- run: |
|
||||
cargo clippy --all \
|
||||
--exclude cb \
|
||||
--features libm-test/build-musl,libm-test/test-multiprecision \
|
||||
--all-targets
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
#![feature(core_intrinsics)]
|
||||
#![allow(internal_features)]
|
||||
#![allow(dead_code)]
|
||||
#![no_std]
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[allow(clippy::all)] // We don't get `libm`'s list of `allow`s, so just ignore Clippy.
|
||||
#[path = "../../../src/math/mod.rs"]
|
||||
pub mod libm;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub fn ceil(x: f64) -> f64 {
|
|||
}
|
||||
|
||||
let u: u64 = x.to_bits();
|
||||
let e: i64 = (u >> 52 & 0x7ff) as i64;
|
||||
let e: i64 = ((u >> 52) & 0x7ff) as i64;
|
||||
let y: f64;
|
||||
|
||||
if e >= 0x3ff + 52 || x == 0. {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ pub fn exp10(x: f64) -> f64 {
|
|||
let (mut y, n) = modf(x);
|
||||
let u: u64 = n.to_bits();
|
||||
/* fabs(n) < 16 without raising invalid on nan */
|
||||
if (u >> 52 & 0x7ff) < 0x3ff + 4 {
|
||||
if ((u >> 52) & 0x7ff) < 0x3ff + 4 {
|
||||
if y == 0.0 {
|
||||
return i!(P10, ((n as isize) + 15) as usize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub fn exp10f(x: f32) -> f32 {
|
|||
let (mut y, n) = modff(x);
|
||||
let u = n.to_bits();
|
||||
/* fabsf(n) < 8 without raising invalid on nan */
|
||||
if (u >> 23 & 0xff) < 0x7f + 3 {
|
||||
if ((u >> 23) & 0xff) < 0x7f + 3 {
|
||||
if y == 0.0 {
|
||||
return i!(P10, ((n as isize) + 7) as usize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ pub fn exp2(mut x: f64) -> f64 {
|
|||
|
||||
/* Filter out exceptional cases. */
|
||||
let ui = f64::to_bits(x);
|
||||
let ix = ui >> 32 & 0x7fffffff;
|
||||
let ix = (ui >> 32) & 0x7fffffff;
|
||||
if ix >= 0x408ff000 {
|
||||
/* |x| >= 1022 or nan */
|
||||
if ix >= 0x40900000 && ui >> 63 == 0 {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
|||
d -= 64;
|
||||
if d == 0 {
|
||||
} else if d < 64 {
|
||||
rlo = rhi << (64 - d) | rlo >> d | ((rlo << (64 - d)) != 0) as u64;
|
||||
rlo = (rhi << (64 - d)) | (rlo >> d) | ((rlo << (64 - d)) != 0) as u64;
|
||||
rhi = rhi >> d;
|
||||
} else {
|
||||
rlo = 1;
|
||||
|
|
@ -95,7 +95,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
|||
if d == 0 {
|
||||
zlo = nz.m;
|
||||
} else if d < 64 {
|
||||
zlo = nz.m >> d | ((nz.m << (64 - d)) != 0) as u64;
|
||||
zlo = (nz.m >> d) | ((nz.m << (64 - d)) != 0) as u64;
|
||||
} else {
|
||||
zlo = 1;
|
||||
}
|
||||
|
|
@ -127,11 +127,11 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
|||
e += 64;
|
||||
d = rhi.leading_zeros() as i32 - 1;
|
||||
/* note: d > 0 */
|
||||
rhi = rhi << d | rlo >> (64 - d) | ((rlo << d) != 0) as u64;
|
||||
rhi = (rhi << d) | (rlo >> (64 - d)) | ((rlo << d) != 0) as u64;
|
||||
} else if rlo != 0 {
|
||||
d = rlo.leading_zeros() as i32 - 1;
|
||||
if d < 0 {
|
||||
rhi = rlo >> 1 | (rlo & 1);
|
||||
rhi = (rlo >> 1) | (rlo & 1);
|
||||
} else {
|
||||
rhi = rlo << d;
|
||||
}
|
||||
|
|
@ -165,7 +165,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
|||
/* one bit is lost when scaled, add another top bit to
|
||||
only round once at conversion if it is inexact */
|
||||
if (rhi << 53) != 0 {
|
||||
i = (rhi >> 1 | (rhi & 1) | 1 << 62) as i64;
|
||||
i = ((rhi >> 1) | (rhi & 1) | (1 << 62)) as i64;
|
||||
if sign != 0 {
|
||||
i = -i;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ pub fn fma(x: f64, y: f64, z: f64) -> f64 {
|
|||
} else {
|
||||
/* only round once when scaled */
|
||||
d = 10;
|
||||
i = ((rhi >> d | ((rhi << (64 - d)) != 0) as u64) << d) as i64;
|
||||
i = (((rhi >> d) | ((rhi << (64 - d)) != 0) as u64) << d) as i64;
|
||||
if sign != 0 {
|
||||
i = -i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
pub fn fmod(x: f64, y: f64) -> f64 {
|
||||
let mut uxi = x.to_bits();
|
||||
let mut uyi = y.to_bits();
|
||||
let mut ex = (uxi >> 52 & 0x7ff) as i64;
|
||||
let mut ey = (uyi >> 52 & 0x7ff) as i64;
|
||||
let mut ex = ((uxi >> 52) & 0x7ff) as i64;
|
||||
let mut ey = ((uyi >> 52) & 0x7ff) as i64;
|
||||
let sx = uxi >> 63;
|
||||
let mut i;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use core::f32;
|
|||
pub fn fmodf(x: f32, y: f32) -> f32 {
|
||||
let mut uxi = x.to_bits();
|
||||
let mut uyi = y.to_bits();
|
||||
let mut ex = (uxi >> 23 & 0xff) as i32;
|
||||
let mut ey = (uyi >> 23 & 0xff) as i32;
|
||||
let mut ex = ((uxi >> 23) & 0xff) as i32;
|
||||
let mut ey = ((uyi >> 23) & 0xff) as i32;
|
||||
let sx = uxi & 0x80000000;
|
||||
let mut i;
|
||||
|
||||
|
|
|
|||
|
|
@ -171,10 +171,10 @@ pub fn y1(x: f64) -> f64 {
|
|||
lx = get_low_word(x);
|
||||
|
||||
/* y1(nan)=nan, y1(<0)=nan, y1(0)=-inf, y1(inf)=0 */
|
||||
if (ix << 1 | lx) == 0 {
|
||||
if (ix << 1) | lx == 0 {
|
||||
return -1.0 / 0.0;
|
||||
}
|
||||
if (ix >> 31) != 0 {
|
||||
if ix >> 31 != 0 {
|
||||
return 0.0 / 0.0;
|
||||
}
|
||||
if ix >= 0x7ff00000 {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub fn jn(n: i32, mut x: f64) -> f64 {
|
|||
ix &= 0x7fffffff;
|
||||
|
||||
// -lx == !lx + 1
|
||||
if (ix | (lx | ((!lx).wrapping_add(1))) >> 31) > 0x7ff00000 {
|
||||
if ix | ((lx | (!lx).wrapping_add(1)) >> 31) > 0x7ff00000 {
|
||||
/* nan */
|
||||
return x;
|
||||
}
|
||||
|
|
@ -265,7 +265,7 @@ pub fn yn(n: i32, x: f64) -> f64 {
|
|||
ix &= 0x7fffffff;
|
||||
|
||||
// -lx == !lx + 1
|
||||
if (ix | (lx | ((!lx).wrapping_add(1))) >> 31) > 0x7ff00000 {
|
||||
if ix | ((lx | (!lx).wrapping_add(1)) >> 31) > 0x7ff00000 {
|
||||
/* nan */
|
||||
return x;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ pub fn log10(mut x: f64) -> f64 {
|
|||
hx += 0x3ff00000 - 0x3fe6a09e;
|
||||
k += (hx >> 20) as i32 - 0x3ff;
|
||||
hx = (hx & 0x000fffff) + 0x3fe6a09e;
|
||||
ui = (hx as u64) << 32 | (ui & 0xffffffff);
|
||||
ui = ((hx as u64) << 32) | (ui & 0xffffffff);
|
||||
x = f64::from_bits(ui);
|
||||
|
||||
f = x - 1.0;
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ pub fn log1p(x: f64) -> f64 {
|
|||
}
|
||||
/* reduce u into [sqrt(2)/2, sqrt(2)] */
|
||||
hu = (hu & 0x000fffff) + 0x3fe6a09e;
|
||||
ui = (hu as u64) << 32 | (ui & 0xffffffff);
|
||||
ui = ((hu as u64) << 32) | (ui & 0xffffffff);
|
||||
f = f64::from_bits(ui) - 1.;
|
||||
}
|
||||
hfsq = 0.5 * f * f;
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ pub fn log2(mut x: f64) -> f64 {
|
|||
hx += 0x3ff00000 - 0x3fe6a09e;
|
||||
k += (hx >> 20) as i32 - 0x3ff;
|
||||
hx = (hx & 0x000fffff) + 0x3fe6a09e;
|
||||
ui = (hx as u64) << 32 | (ui & 0xffffffff);
|
||||
ui = ((hx as u64) << 32) | (ui & 0xffffffff);
|
||||
x = f64::from_bits(ui);
|
||||
|
||||
f = x - 1.0;
|
||||
|
|
|
|||
|
|
@ -359,5 +359,5 @@ fn with_set_low_word(f: f64, lo: u32) -> f64 {
|
|||
|
||||
#[inline]
|
||||
fn combine_words(hi: u32, lo: u32) -> f64 {
|
||||
f64::from_bits((hi as u64) << 32 | lo as u64)
|
||||
f64::from_bits(((hi as u64) << 32) | lo as u64)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pub fn modf(x: f64) -> (f64, f64) {
|
|||
let rv2: f64;
|
||||
let mut u = x.to_bits();
|
||||
let mask: u64;
|
||||
let e = ((u >> 52 & 0x7ff) as i32) - 0x3ff;
|
||||
let e = (((u >> 52) & 0x7ff) as i32) - 0x3ff;
|
||||
|
||||
/* no fractional part */
|
||||
if e >= 52 {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ pub fn modff(x: f32) -> (f32, f32) {
|
|||
let rv2: f32;
|
||||
let mut u: u32 = x.to_bits();
|
||||
let mask: u32;
|
||||
let e = ((u >> 23 & 0xff) as i32) - 0x7f;
|
||||
let e = (((u >> 23) & 0xff) as i32) - 0x7f;
|
||||
|
||||
/* no fractional part */
|
||||
if e >= 23 {
|
||||
|
|
|
|||
|
|
@ -16,14 +16,14 @@ pub fn nextafter(x: f64, y: f64) -> f64 {
|
|||
if ay == 0 {
|
||||
return y;
|
||||
}
|
||||
ux_i = (uy_i & 1_u64 << 63) | 1;
|
||||
} else if ax > ay || ((ux_i ^ uy_i) & 1_u64 << 63) != 0 {
|
||||
ux_i = (uy_i & (1_u64 << 63)) | 1;
|
||||
} else if ax > ay || ((ux_i ^ uy_i) & (1_u64 << 63)) != 0 {
|
||||
ux_i -= 1;
|
||||
} else {
|
||||
ux_i += 1;
|
||||
}
|
||||
|
||||
let e = ux_i >> 52 & 0x7ff;
|
||||
let e = (ux_i >> 52) & 0x7ff;
|
||||
// raise overflow if ux.f is infinite and x is finite
|
||||
if e == 0x7ff {
|
||||
force_eval!(x + x);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
pub fn rint(x: f64) -> f64 {
|
||||
let one_over_e = 1.0 / f64::EPSILON;
|
||||
let as_u64: u64 = x.to_bits();
|
||||
let exponent: u64 = as_u64 >> 52 & 0x7ff;
|
||||
let exponent: u64 = (as_u64 >> 52) & 0x7ff;
|
||||
let is_positive = (as_u64 >> 63) == 0;
|
||||
if exponent >= 0x3ff + 52 {
|
||||
x
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
pub fn rintf(x: f32) -> f32 {
|
||||
let one_over_e = 1.0 / f32::EPSILON;
|
||||
let as_u32: u32 = x.to_bits();
|
||||
let exponent: u32 = as_u32 >> 23 & 0xff;
|
||||
let exponent: u32 = (as_u32 >> 23) & 0xff;
|
||||
let is_positive = (as_u32 >> 31) == 0;
|
||||
if exponent >= 0x7f + 23 {
|
||||
x
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ pub fn sqrt(x: f64) -> f64 {
|
|||
ix1 |= sign;
|
||||
}
|
||||
ix0 += m << 20;
|
||||
f64::from_bits((ix0 as u64) << 32 | ix1.0 as u64)
|
||||
f64::from_bits(((ix0 as u64) << 32) | ix1.0 as u64)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn trunc(x: f64) -> f64 {
|
|||
let x1p120 = f64::from_bits(0x4770000000000000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
let mut i: u64 = x.to_bits();
|
||||
let mut e: i64 = (i >> 52 & 0x7ff) as i64 - 0x3ff + 12;
|
||||
let mut e: i64 = ((i >> 52) & 0x7ff) as i64 - 0x3ff + 12;
|
||||
let m: u64;
|
||||
|
||||
if e >= 52 + 12 {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub fn truncf(x: f32) -> f32 {
|
|||
let x1p120 = f32::from_bits(0x7b800000); // 0x1p120f === 2 ^ 120
|
||||
|
||||
let mut i: u32 = x.to_bits();
|
||||
let mut e: i32 = (i >> 23 & 0xff) as i32 - 0x7f + 9;
|
||||
let mut e: i32 = ((i >> 23) & 0xff) as i32 - 0x7f + 9;
|
||||
let m: u32;
|
||||
|
||||
if e >= 23 + 9 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue