in gmp-impl.h we have /* Like udiv_qrnnd_preinv2, but for for any value D. DNORM is D shifted left so that its most significant bit is set. LGUP is ceil(log2(D)). */ #define udiv_qrnnd_preinv2gen(q, r, nh, nl, d, di, dnorm, lgup) Surely lgup should be floor(log2(D))+1