54
54
// 2 ^ sig_total_bits, representation of what can be accounted for with subnormals
55
55
let f_exp_subnorm = F :: from_parts ( false , sig_total_bits + F :: EXP_BIAS , zero) ;
56
56
57
- dbg ! ( ( Hexf ( f_exp_max ) , Hexf ( f_exp_min ) , Hexf ( f_exp_subnorm ) ) ) ;
58
-
57
+ dbg ! ( exp_max , exp_min , sig_total_bits , sig_total_bits + F :: EXP_BIAS ) ;
58
+ dbg ! ( Hexf ( f_exp_max ) , Hexf ( f_exp_min ) , Hexf ( f_exp_subnorm ) ) ;
59
59
dbg ! ( Hexf ( x) , n) ;
60
60
61
61
// The goal is to multiply `x` by a scale factor that applies `n`. However, there are cases
@@ -86,13 +86,16 @@ where
86
86
let add = -exp_min - sig_total_bits as i32 ;
87
87
dbg ! ( Hexf ( mul) , add) ;
88
88
89
- if n < exp_min + sig_total_bits as i32 {
89
+ if n < exp_min - sig_total_bits as i32 {
90
+ dbg ! ( "block 1" ) ;
90
91
x *= f_exp_min;
91
92
n += -exp_min;
93
+ dbg ! ( Hexf ( x) , n) ;
92
94
93
- if n < exp_min + sig_total_bits as i32 {
95
+ if n < exp_min - sig_total_bits as i32 {
94
96
x *= f_exp_min;
95
97
n += -exp_min;
98
+ dbg ! ( Hexf ( x) , n) ;
96
99
97
100
// if n < exp_min + sig_total_bits as i32 {
98
101
// x *= f_exp_min;
@@ -105,9 +108,33 @@ where
105
108
106
109
if n < exp_min {
107
110
n = exp_min;
111
+ dbg ! ( Hexf ( x) , n) ;
108
112
}
109
113
// }
114
+ } else if n < exp_min {
115
+ // only for f16
116
+
117
+ x *= mul;
118
+ n += add;
119
+
120
+ dbg ! ( Hexf ( x) , n) ;
121
+ if n < exp_min {
122
+ n = exp_min;
123
+ dbg ! ( Hexf ( x) , n) ;
124
+ }
110
125
}
126
+ } else if n < exp_min {
127
+ // dbg!("block 2");
128
+ // // only for f16
129
+
130
+ // x *= mul;
131
+ // n += add;
132
+
133
+ // dbg!(Hexf(x), n);
134
+ // if n < exp_min {
135
+ // n = exp_min;
136
+ // dbg!(Hexf(x), n);
137
+ // }
111
138
}
112
139
113
140
// if n < exp_min {
@@ -262,28 +289,4 @@ mod tests {
262
289
fn spec_test_f128 ( ) {
263
290
spec_test :: < f128 > ( ) ;
264
291
}
265
-
266
- // #[test]
267
- // fn foobar32() {
268
- // let x = hf32!("0x1.fffffep+127");
269
- // let n = -2147483639;
270
- // scalbn(x, n);
271
- // std::eprintln!();
272
- // let x = hf32!("0x1.fffffep-126");
273
- // let n = 2147483639;
274
- // scalbn(x, n);
275
- // panic!();
276
- // }
277
-
278
- // #[test]
279
- // fn foobar16() {
280
- // let x = hf16!("0x1.ffp+15");
281
- // let n = -2147483639;
282
- // scalbn(x, n);
283
- // std::eprintln!();
284
- // let x = hf16!("0x1.ffp-15");
285
- // let n = 2147483639;
286
- // scalbn(x, n);
287
- // panic!();
288
- // }
289
292
}
0 commit comments