@@ -24,33 +24,19 @@ where
24
24
{
25
25
let zero = IntTy :: < F > :: ZERO ;
26
26
27
- // if n == 0 || x == F::ZERO || x.is_nan() || x.is_infinite() {
28
- // return x;
29
- // }
30
-
31
27
// Bits including the implicit bit
32
28
let sig_total_bits = F :: SIG_BITS + 1 ;
33
29
34
30
// Maximum and minimum values when biased
35
31
let exp_max: i32 = F :: EXP_BIAS as i32 ;
36
32
let exp_min = -( exp_max - 1 ) ;
37
- // let exp_min_with_subnorm = -((F::EXP_BIAS + F::SIG_BITS + 1) as i32);
38
-
39
- // // let x_exp = x.exp();
40
- // // let x_sig = x.frac();
41
-
42
- // if n > exp_max {
43
- // return F::INFINITY * x.signum();
44
- // }
45
-
46
- // if n < exp_min_with_subnorm {
47
- // return F::ZERO * x.signum();
48
- // }
49
33
50
34
// 2 ^ Emax, where Emax is the maximum biased exponent value (1023 for f64)
51
- let f_exp_max = F :: from_bits ( F :: Int :: cast_from ( F :: EXP_BIAS << 1 ) << F :: SIG_BITS ) ;
35
+ let f_exp_max = F :: from_parts ( false , F :: EXP_BIAS << 1 , zero) ;
36
+
52
37
// 2 ^ Emin, where Emin is the minimum biased exponent value (-1022 for f64)
53
- let f_exp_min = F :: from_bits ( IntTy :: < F > :: ONE << F :: SIG_BITS ) ;
38
+ let f_exp_min = F :: from_parts ( false , 1 , zero) ;
39
+
54
40
// 2 ^ sig_total_bits, representation of what can be accounted for with subnormals
55
41
let f_exp_subnorm = F :: from_parts ( false , sig_total_bits + F :: EXP_BIAS , zero) ;
56
42
79
65
}
80
66
}
81
67
82
- x * F :: from_bits ( F :: Int :: cast_from ( F :: EXP_BIAS as i32 + n) << F :: SIG_BITS )
68
+ x * F :: from_parts ( false , ( F :: EXP_BIAS as i32 + n) as u32 , zero )
83
69
}
84
70
85
71
#[ cfg( test) ]
0 commit comments