@@ -23,13 +23,12 @@ where
23
23
let one = F :: Int :: ONE ;
24
24
let u0: F = F :: U0 ;
25
25
let u1: F = F :: U1 ;
26
- let rsc = F :: RSC ;
27
26
let off = F :: OFF ;
28
27
29
28
/* rm=0 for rounding to nearest, and other values for directed roundings */
30
29
let hx = x. to_bits ( ) ;
31
30
let mut mant: F :: Int = hx & F :: SIG_MASK ;
32
- let sign: F :: Int = hx >> ( F :: BITS - 1 ) ;
31
+ let sign: F :: Int = hx & F :: SIGN_MASK ;
33
32
let neg = x. is_sign_negative ( ) ;
34
33
35
34
let mut e: u32 = x. exp ( ) ;
@@ -61,19 +60,19 @@ where
61
60
62
61
/* 2^(3k+it) <= x < 2^(3k+it+1), with 0 <= it <= 3 */
63
62
cvt5 += F :: Int :: cast_from ( it) << F :: SIG_BITS ;
64
- cvt5 |= sign << ( F :: BITS - 1 ) ;
63
+ cvt5 |= sign;
65
64
let zz: F = F :: from_bits ( cvt5) ;
66
65
67
66
/* cbrt(x) = cbrt(zz)*2^(et-1365) where 1 <= zz < 8 */
68
67
let mut isc = F :: ESCALE [ it as usize ] . to_bits ( ) ; // todo: index
69
- isc |= sign << ( F :: BITS - 1 ) ;
68
+ isc |= sign;
70
69
let cvt2 = isc;
71
70
let z: F = F :: from_bits ( cvt1) ;
72
71
73
72
/* cbrt(zz) = cbrt(z)*isc, where isc encodes 1, 2^(1/3) or 2^(2/3),
74
73
and 1 <= z < 2 */
75
74
let r: F = F :: ONE / z;
76
- let rr: F = r * rsc [ ( ( it as usize ) << 1 ) | neg as usize ] ;
75
+ let rr: F = r * F :: RSC [ ( ( it as usize ) << 1 ) | neg as usize ] ;
77
76
let z2: F = z * z;
78
77
let c0: F = F :: C [ 0 ] + z * F :: C [ 1 ] ;
79
78
let c2: F = F :: C [ 2 ] + z * F :: C [ 3 ] ;
@@ -155,7 +154,7 @@ where
155
154
if round != Round :: Nearest {
156
155
for ( a, b) in F :: WLIST {
157
156
if azz == a {
158
- let tmp = if F :: Int :: from ( round as u8 ) + sign == F :: Int :: cast_from ( 2 ) {
157
+ let tmp = if F :: Int :: from ( round as u8 + neg as u8 ) == F :: Int :: cast_from ( 2 ) {
159
158
F :: TWO_POW_NEG_SIG_BITS
160
159
} else {
161
160
F :: ZERO
0 commit comments