Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 62e2506

Browse files
committed
fix jn, ilogb
1 parent 68c49a2 commit 62e2506

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

build.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ mod musl_reference_tests {
2626

2727
// These files are all internal functions or otherwise miscellaneous, not
2828
// defining a function we want to test.
29-
const IGNORED_FILES: &[&str] = &[
30-
"fenv.rs",
31-
];
29+
const IGNORED_FILES: &[&str] = &["fenv.rs"];
3230

3331
struct Function {
3432
name: String,

src/math/ilogb.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const FP_ILOGBNAN: i32 = -1 - ((!0) >> 1);
1+
const FP_ILOGBNAN: i32 = -1 - 0x7fffffff;
22
const FP_ILOGB0: i32 = FP_ILOGBNAN;
33

44
pub fn ilogb(x: f64) -> i32 {
@@ -17,15 +17,15 @@ pub fn ilogb(x: f64) -> i32 {
1717
e -= 1;
1818
i <<= 1;
1919
}
20-
return e;
21-
}
22-
if e == 0x7ff {
20+
e
21+
} else if e == 0x7ff {
2322
force_eval!(0.0 / 0.0);
2423
if (i << 12) != 0 {
25-
return FP_ILOGBNAN;
24+
FP_ILOGBNAN
2625
} else {
27-
return i32::max_value();
26+
i32::max_value()
2827
}
28+
} else {
29+
e - 0x3ff
2930
}
30-
return e - 0x3ff;
3131
}

src/math/ilogbf.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const FP_ILOGBNAN: i32 = -1 - ((!0) >> 1);
1+
const FP_ILOGBNAN: i32 = -1 - 0x7fffffff;
22
const FP_ILOGB0: i32 = FP_ILOGBNAN;
33

44
pub fn ilogbf(x: f32) -> i32 {
@@ -17,15 +17,15 @@ pub fn ilogbf(x: f32) -> i32 {
1717
e -= 1;
1818
i <<= 1;
1919
}
20-
return e;
21-
}
22-
if e == 0xff {
20+
e
21+
} else if e == 0xff {
2322
force_eval!(0.0 / 0.0);
2423
if (i << 9) != 0 {
25-
return FP_ILOGBNAN;
24+
FP_ILOGBNAN
2625
} else {
27-
return i32::max_value();
26+
i32::max_value()
2827
}
28+
} else {
29+
e - 0x7f
2930
}
30-
return e - 0x7f;
3131
}

src/math/jn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub fn jn(n: i32, mut x: f64) -> f64 {
5454
ix &= 0x7fffffff;
5555

5656
// -lx == !lx + 1
57-
if (ix | (lx | (!lx + 1)) >> 31) > 0x7ff00000 {
57+
if (ix | (lx | ((!lx).wrapping_add(1))) >> 31) > 0x7ff00000 {
5858
/* nan */
5959
return x;
6060
}
@@ -268,7 +268,7 @@ pub fn yn(n: i32, x: f64) -> f64 {
268268
ix &= 0x7fffffff;
269269

270270
// -lx == !lx + 1
271-
if (ix | (lx | (!lx + 1)) >> 31) > 0x7ff00000 {
271+
if (ix | (lx | ((!lx).wrapping_add(1))) >> 31) > 0x7ff00000 {
272272
/* nan */
273273
return x;
274274
}

0 commit comments

Comments
 (0)