Skip to content

Commit 8fbdfe5

Browse files
committed
More simplify
1 parent 554ed0d commit 8fbdfe5

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/float/div.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ where
104104
///
105105
/// ASSUMPTION: the initial estimate should have at least 8 bits of precision. If this is not
106106
/// true, results will be inaccurate.
107-
const fn calc_iterations<F: Float>() -> (usize, usize) {
107+
const fn get_iterations<F: Float>() -> (usize, usize) {
108108
// Precision doubles with each iteration
109109
let total_iterations = F::BITS.ilog2() as usize - 2;
110110

@@ -137,16 +137,7 @@ const fn calc_iterations<F: Float>() -> (usize, usize) {
137137
///
138138
/// Add 2 to U_N due to final decrement.
139139
const fn reciprocal_precision<F: Float>() -> u16 {
140-
let (half_iterations, full_iterations) = calc_iterations::<F>();
141-
142-
// if !Self::USE_NATIVE_FULL_ITERATIONS {
143-
// if Self::FULL_ITERATIONS != 1 {
144-
// panic!("Only a single emulated full iteration is supported");
145-
// }
146-
// if !(Self::HALF_ITERATIONS > 0) {
147-
// panic!("Invalid number of half iterations");
148-
// }
149-
// }
140+
let (half_iterations, full_iterations) = get_iterations::<F>();
150141

151142
if full_iterations < 1 {
152143
panic!("Must have at least one full iteration");
@@ -248,7 +239,7 @@ where
248239
let inf_rep = exponent_mask;
249240
let quiet_bit = implicit_bit >> 1;
250241
let qnan_rep = exponent_mask | quiet_bit;
251-
let (half_iterations, full_iterations) = calc_iterations::<F>();
242+
let (half_iterations, full_iterations) = get_iterations::<F>();
252243
let recip_precision = reciprocal_precision::<F>();
253244

254245
let a_rep = a.repr();
@@ -640,6 +631,15 @@ where
640631
F::from_repr(abs_result | quotient_sign)
641632
}
642633

634+
fn iter_once<I>(x_uq0: I, b_uq1: I) -> I
635+
where
636+
I: Int + HInt,
637+
<I as HInt>::D: ops::Shr<u32, Output = <I as HInt>::D>,
638+
{
639+
let corr_uq1: I = I::ZERO.wrapping_sub(x_uq0.widen_mul(b_uq1).hi());
640+
(x_uq0.widen_mul(corr_uq1) >> (I::BITS - 1)).lo()
641+
}
642+
643643
intrinsics! {
644644
#[avr_skip]
645645
#[arm_aeabi_alias = __aeabi_fdiv]

0 commit comments

Comments
 (0)