potential bug in the manual

Paul Zimmermann Paul.Zimmermann at loria.fr
Tue Apr 24 17:28:55 CEST 2007


       Hi,

the gmp manual (4.2.1) says:

 - Function: mp_limb_t mpn_submul_1 (mp_limb_t *RP, const mp_limb_t
          *S1P, mp_size_t N, mp_limb_t S2LIMB)
     Multiply {S1P, N} and S2LIMB, and subtract the N least significant
     limbs of the product from {RP, N} and write the result to RP.
     Return the most significant limb of the product, minus borrow-out
     from the subtraction.                            ^^^^^^^^^^^^^^^^

It seems to me it should be "plus borrow-out from the subtraction" instead.
Indeed, if the N least significant limbs of the product {S1P, N} * S2LIMB are
larger than {RP, N}, then the limb-borrow is C+1, where I denote C the most
significant limb of {S1P, N} * S2LIMB.

Sorry if my reasoning is wrong, anyway more details would be welcome.

Regards,
Paul Zimmermann


More information about the gmp-bugs mailing list