udiv_qr_3by2 vs divappr

paul zimmermann Paul.Zimmermann at inria.fr
Wed May 9 13:09:52 UTC 2018


> From: nisse at lysator.liu.se (Niels Möller)
> Date: Sat, 28 Apr 2018 13:27:36 +0200
> [...]
> Inputs are a two limb normlized divisor, {d1, d0}, d1 >= B/2, and two
> numerator words, {n2, n1}, which must be less than {d1, d0}. [...]

if you use udiv_qr_3by2 to divide (say) a 6-limb number by a 3-limb number,
then in the schoolbook loop you might have {n2, n1} = {d1, d0}, in the case
where n0 is smaller than the next divisor limb d[-1].

If it is the responsibility of the caller to ensure {n2, n1} < {d1, d0},
then every caller of udiv_qr_3by2 must deal with that special case.

In my opinion, it would be simpler to allow {n2, n1} = {d1, d0}, and
return q=GMP_NUMB_MAX in that case.


More information about the gmp-devel mailing list