mpf: which bug should we correct? (doc or code)

Torbjörn Granlund tg at
Sun Jun 1 10:07:55 UTC 2014

Let me supply some more information.

The claim that we calculate as if to infinite precision is breached in
places where it is non-trivial to fix.

An example:

In mpf_mul we just grab (up to) the prec most significant limbs of both
input operands, where prec is the destination operand's (rounded-up)
precision.  Thanks to the rounding-up this will be at least one bit more
than the user requested when initialising the destination variable.

Clearly, truncating the input variables prior to performing the multiply
will not generate the result we claim to be generating.

We could still truncate input variables, but then (iteratively) compute
a more and more precise product if least significant bits are all ones.

And in mpf_mul_ui we actually do exactly that! I cannot recall the
background to this lack of coherence; this code was written long ago and
is not actively maintained.

Fixing this requires some effort, and I think there is little point in
fixing just one place, and ignore the rest.

Please encrypt, key id 0xC8601622

More information about the gmp-devel mailing list