Skip to content

Commit 8acb24c

Browse files
committed
try to fix rust-lang#170
Signed-off-by: Benjamin Schultzer <[email protected]>
1 parent fb0547e commit 8acb24c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/math/jnf.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
7575
}
7676
temp = 0.5 * x;
7777
b = temp;
78-
a = 1.0;
78+
let mut a = 1;
7979
i = 2;
8080
while i <= nm1 + 1 {
81-
a *= i as f32; /* a = n! */
81+
a *= i; /* a = n! */
8282
b *= temp; /* b = (x/2)^n */
8383
i += 1;
8484
}
85-
b = b / a;
85+
b /= a as f32;
8686
} else {
8787
/* use backward recurrence */
8888
/* x x^2 x^2
@@ -124,7 +124,7 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
124124
let mut k: i32;
125125

126126
nf = (nm1 as f32) + 1.0;
127-
w = 2.0 * (nf as f32) / x;
127+
w = 2.0 * nf / x;
128128
h = 2.0 / x;
129129
z = w + h;
130130
q0 = w;

src/math/logf.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ pub fn logf(mut x: f32) -> f32 {
2929
let mut ix = x.to_bits();
3030
let mut k = 0i32;
3131

32+
/* Fix sign of zero with downward rounding when x==1. */
33+
if (ix == 0x3f800000) {
34+
return 0.;
35+
}
3236
if (ix < 0x00800000) || ((ix >> 31) != 0) {
3337
/* x < 2**-126 */
3438
if ix << 1 == 0 {

0 commit comments

Comments
 (0)