127 constexpr u32 kBase = 65536u;
128 if (divisor == 0u || hi >= divisor) {
135 const u32 d = divisor << shift;
136 const u32 d_high = d >> 16;
137 const u32 d_low = d & 0xFFFFu;
141 const u32 n_high = shift == 0 ? hi : ((hi << shift) | (lo >> (32 - shift)));
142 const u32 n_low = lo << shift;
143 const u32 n_low_high = n_low >> 16;
144 const u32 n_low_low = n_low & 0xFFFFu;
146 u32 quotient_high = n_high / d_high;
147 u32 remainder = n_high - quotient_high * d_high;
148 while (quotient_high >= kBase ||
149 static_cast<u64>(quotient_high) * d_low >
150 static_cast<u64>(kBase) * remainder + n_low_high) {
153 if (remainder >= kBase) {
161 static_cast<u32
>(n_high * kBase + n_low_high - quotient_high * d);
163 u32 quotient_low = partial / d_high;
164 remainder = partial - quotient_low * d_high;
165 while (quotient_low >= kBase ||
166 static_cast<u64>(quotient_low) * d_low >
167 static_cast<u64>(kBase) * remainder + n_low_low) {
170 if (remainder >= kBase) {
175 return quotient_high * kBase + quotient_low;
FL_FIXED_POINT_DIVIDE_INLINE u32 divide64By32(u32 hi, u32 lo, u32 divisor) FL_NO_EXCEPT
(hi:lo) / divisor, for a quotient that fits 32 bits.