bug in gmp_printf (?)

Zimmermann Paul Paul.Zimmermann at loria.fr
Thu Aug 18 15:54:33 CEST 2011


       Marc,

> so you think the issue is wider than just <1 rounded to exactly 1, and 
> that it can indeed cause real trouble?

in practice I think it only happens for 0.11111... (in binary) rounded to 1,
since for the problem to happen we need:

1) that the input is rounded up to an exact power of ten
2) that the EXP(f) * (mp_bases[ABS(p->base)].chars_per_limb + 1) upper bound
   is tight for EXP(f) > 0, which requires that:
   2a) 2^32 or 2^64 is very near 10^(mp_bases[ABS(p->base)].chars_per_limb + 1)
   2b) the input most significand limb is near 2^32 or 2^64

(and similarly for EXP(f) < 0).

I guess we can prove that cannot happen, at least for BITS_PER_LIMB=32 or 64.

Now I only concentrated on ensuring the failed assertion becomes true.

Maybe if the problem only occurs for 0.11111... rounded to 1, one can
change that assertion in that case, without changing the computation of
ndigits. I didn't analyze this.

Paul

   


More information about the gmp-bugs mailing list