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

Commit 16b568e

Browse files
committed
cleanup
1 parent 0e1d82b commit 16b568e

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

src/math/generic/scalbn.rs

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,19 @@ where
2424
{
2525
let zero = IntTy::<F>::ZERO;
2626

27-
// if n == 0 || x == F::ZERO || x.is_nan() || x.is_infinite() {
28-
// return x;
29-
// }
30-
3127
// Bits including the implicit bit
3228
let sig_total_bits = F::SIG_BITS + 1;
3329

3430
// Maximum and minimum values when biased
3531
let exp_max: i32 = F::EXP_BIAS as i32;
3632
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-
// }
4933

5034
// 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+
5237
// 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+
5440
// 2 ^ sig_total_bits, representation of what can be accounted for with subnormals
5541
let f_exp_subnorm = F::from_parts(false, sig_total_bits + F::EXP_BIAS, zero);
5642

@@ -79,7 +65,7 @@ where
7965
}
8066
}
8167

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)
8369
}
8470

8571
#[cfg(test)]

0 commit comments

Comments
 (0)