Skip to content

Commit d35ef20

Browse files
committed
div work
1 parent 477af0a commit d35ef20

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/float/div.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,27 @@ use core::mem::size_of;
7878

7979
macro_rules! guess {
8080
($ty:ty) => {
81-
const { (INITIAL_GUESS >> (u128::BITS - <$ty>::BITS)) as $ty }
81+
const { (C_U128 >> (u128::BITS - <$ty>::BITS)) as $ty }
8282
};
8383
}
8484

85-
const INITIAL_GUESS: u128 = 0x7504f333f9de6108b2fb1366eaa6a542;
85+
const C_U128: u128 = 0x7504f333f9de6108b2fb1366eaa6a542;
86+
87+
/// C is (3/4 + 1/sqrt(2)) - 1 truncated to W0 fractional bits as UQ0.HW
88+
/// with W0 being either 16 or 32 and W0 <= HW.
89+
/// That is, C is the aforementioned 3/4 + 1/sqrt(2) constant (from which
90+
/// b/2 is subtracted to obtain x0) wrapped to [0, 1) range.
91+
macro_rules! half_width_c {
92+
($ty:ty) => {
93+
const { (C_U128 >> (u128::BITS - <$ty>::BITS)) as $ty }
94+
};
95+
}
8696

8797
/// Type-specific configuration used for float division
8898
trait FloatDivision: Float
8999
where
90100
Self::Int: DInt,
91101
{
92-
/// C is (3/4 + 1/sqrt(2)) - 1 truncated to W0 fractional bits as UQ0.HW
93-
/// with W0 being either 16 or 32 and W0 <= HW.
94-
/// That is, C is the aforementioned 3/4 + 1/sqrt(2) constant (from which
95-
/// b/2 is subtracted to obtain x0) wrapped to [0, 1) range.
96102
const C_HW: HalfRep<Self>;
97103
}
98104

0 commit comments

Comments
 (0)