fn lldiv0p5(quo: []Limb, rem: *Limb, a: []const Limb, b: HalfLimb) void 4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
4089fn lldiv0p5(quo: []Limb, rem: *Limb, a: []const Limb, b: HalfLimb) void {
assert(a.len > 1 or a[0] >= b);
assert(quo.len >= a.len);
rem.* = 0;
for (a, 0..) |_, ri| {
const i = a.len - ri - 1;
const ai_high = a[i] >> half_limb_bits;
const ai_low = a[i] & ((1 << half_limb_bits) - 1);
// Split the division into two divisions acting on half a limb each. Carry remainder.
const ai_high_with_carry = (rem.* << half_limb_bits) | ai_high;
const ai_high_quo = ai_high_with_carry / b;
rem.* = ai_high_with_carry % b;
const ai_low_with_carry = (rem.* << half_limb_bits) | ai_low;
const ai_low_quo = ai_low_with_carry / b;
rem.* = ai_low_with_carry % b;
quo[i] = (ai_high_quo << half_limb_bits) | ai_low_quo;
}
}