Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 801edce

Browse files
committed
test accounting for sig_total_bits separately
1 parent 7064fb8 commit 801edce

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

src/math/generic/scalbn.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
#![allow(unused)]
2+
13
use super::super::support::Hexf;
24
use super::super::{CastFrom, CastInto, Float, IntTy, MinInt};
35

4-
extern crate std;
5-
use std::dbg;
6+
// extern crate std;
7+
// use std::dbg;
8+
9+
macro_rules! dbg {
10+
($($tt:tt)*) => {};
11+
}
612

713
/// Scale the exponent.
814
///
@@ -68,9 +74,18 @@ where
6874
}
6975
}
7076
} else if n < exp_min {
71-
let mul = f_exp_min * f_exp_subnorm;
72-
let add = (exp_max - 1) - sig_total_bits as i32;
77+
// WIP: for `f16` can this scale by `exp_max` rather than `(max - 1) - sig_bits`?
78+
// That scale is only 3.
79+
//
80+
81+
n += sig_total_bits as i32;
82+
83+
// let mul = f_exp_min * f_exp_subnorm;
84+
// let add = -exp_min - sig_total_bits as i32;
85+
let mul = f_exp_min;
86+
let add = -exp_min;
7387
dbg!(Hexf(mul), add);
88+
let mut b = false;
7489

7590
x *= mul;
7691
n += add;
@@ -79,7 +94,7 @@ where
7994
x *= mul;
8095
n += add;
8196
dbg!(Hexf(x), n);
82-
if F::BITS < 32 {
97+
if F::BITS < 32 && false {
8398
if n < exp_min {
8499
x *= mul;
85100
n += add;
@@ -128,19 +143,21 @@ where
128143
}
129144
} else if n < exp_min {
130145
n = exp_min;
146+
b = true;
131147
dbg!(Hexf(x), n);
132148
}
133149
}
150+
151+
if !b {
152+
n -= sig_total_bits as i32;
153+
}
134154
}
135155

136156
dbg!(Hexf(x), n);
137157
let scale = F::from_parts(false, (F::EXP_BIAS as i32 + n) as u32, zero);
138158
let ret = x * scale;
139159
dbg!(Hexf(scale), Hexf(ret));
140160
ret
141-
142-
// let ret = dbg!(x) * dbg!(F::from_parts(false, (F::EXP_BIAS as i32 + n) as u32, zero));
143-
// dbg!(ret)
144161
}
145162

146163
#[cfg(test)]

0 commit comments

Comments
 (0)