@@ -23,13 +23,12 @@ where
2323 let one = F :: Int :: ONE ;
2424 let u0: F = F :: U0 ;
2525 let u1: F = F :: U1 ;
26- let rsc = F :: RSC ;
2726 let off = F :: OFF ;
2827
2928 /* rm=0 for rounding to nearest, and other values for directed roundings */
3029 let hx = x. to_bits ( ) ;
3130 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 ;
3332 let neg = x. is_sign_negative ( ) ;
3433
3534 let mut e: u32 = x. exp ( ) ;
@@ -61,19 +60,19 @@ where
6160
6261 /* 2^(3k+it) <= x < 2^(3k+it+1), with 0 <= it <= 3 */
6362 cvt5 += F :: Int :: cast_from ( it) << F :: SIG_BITS ;
64- cvt5 |= sign << ( F :: BITS - 1 ) ;
63+ cvt5 |= sign;
6564 let zz: F = F :: from_bits ( cvt5) ;
6665
6766 /* cbrt(x) = cbrt(zz)*2^(et-1365) where 1 <= zz < 8 */
6867 let mut isc = F :: ESCALE [ it as usize ] . to_bits ( ) ; // todo: index
69- isc |= sign << ( F :: BITS - 1 ) ;
68+ isc |= sign;
7069 let cvt2 = isc;
7170 let z: F = F :: from_bits ( cvt1) ;
7271
7372 /* cbrt(zz) = cbrt(z)*isc, where isc encodes 1, 2^(1/3) or 2^(2/3),
7473 and 1 <= z < 2 */
7574 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 ] ;
7776 let z2: F = z * z;
7877 let c0: F = F :: C [ 0 ] + z * F :: C [ 1 ] ;
7978 let c2: F = F :: C [ 2 ] + z * F :: C [ 3 ] ;
@@ -155,7 +154,7 @@ where
155154 if round != Round :: Nearest {
156155 for ( a, b) in F :: WLIST {
157156 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 ) {
159158 F :: TWO_POW_NEG_SIG_BITS
160159 } else {
161160 F :: ZERO
0 commit comments