122 constexpr u32 kBase = 65536u;
123 if (divisor == 0u || hi >= divisor) {
130 const u32 d = divisor << shift;
131 const u32 d_high = d >> 16;
132 const u32 d_low = d & 0xFFFFu;
136 const u32 n_high = shift == 0 ? hi : ((hi << shift) | (lo >> (32 - shift)));
137 const u32 n_low = lo << shift;
138 const u32 n_low_high = n_low >> 16;
139 const u32 n_low_low = n_low & 0xFFFFu;
141 u32 quotient_high = n_high / d_high;
142 u32 remainder = n_high - quotient_high * d_high;
143 while (quotient_high >= kBase ||
144 static_cast<u64>(quotient_high) * d_low >
145 static_cast<u64>(kBase) * remainder + n_low_high) {
148 if (remainder >= kBase) {
156 static_cast<u32
>(n_high * kBase + n_low_high - quotient_high * d);
158 u32 quotient_low = partial / d_high;
159 remainder = partial - quotient_low * d_high;
160 while (quotient_low >= kBase ||
161 static_cast<u64>(quotient_low) * d_low >
162 static_cast<u64>(kBase) * remainder + n_low_low) {
165 if (remainder >= kBase) {
170 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.