File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -75,14 +75,14 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
75
75
}
76
76
temp = 0.5 * x;
77
77
b = temp;
78
- a = 1.0 ;
78
+ let mut a = 1 ;
79
79
i = 2 ;
80
80
while i <= nm1 + 1 {
81
- a *= i as f32 ; /* a = n! */
81
+ a *= i; /* a = n! */
82
82
b *= temp; /* b = (x/2)^n */
83
83
i += 1 ;
84
84
}
85
- b = b / a ;
85
+ b /= a as f32 ;
86
86
} else {
87
87
/* use backward recurrence */
88
88
/* x x^2 x^2
@@ -124,7 +124,7 @@ pub fn jnf(n: i32, mut x: f32) -> f32 {
124
124
let mut k: i32 ;
125
125
126
126
nf = ( nm1 as f32 ) + 1.0 ;
127
- w = 2.0 * ( nf as f32 ) / x;
127
+ w = 2.0 * nf / x;
128
128
h = 2.0 / x;
129
129
z = w + h;
130
130
q0 = w;
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ pub fn logf(mut x: f32) -> f32 {
29
29
let mut ix = x. to_bits ( ) ;
30
30
let mut k = 0i32 ;
31
31
32
+ /* Fix sign of zero with downward rounding when x==1. */
33
+ if ( ix == 0x3f800000 ) {
34
+ return 0. ;
35
+ }
32
36
if ( ix < 0x00800000 ) || ( ( ix >> 31 ) != 0 ) {
33
37
/* x < 2**-126 */
34
38
if ix << 1 == 0 {
You can’t perform that action at this time.
0 commit comments