Binary output of mpf_get_str() has too many bits?

Rick Regan exploringbinary at gmail.com
Wed May 19 18:38:42 CEST 2010


On Wed, May 19, 2010 at 12:06 PM, John Westwood
<john at westwoodsolutions.com>wrote:

>
> The description of mpf_get_str in the manual states:
>
> "If n_digits is 0 then that accurate maximum number of digits are
> generated."
>
> So you could try specifying n_digits as 64, 96 and 128 and you should
> receive
> the correct number of bits when using a base of two.
>
> John


I know that if I specify the number of digits I'll get that amount, but
since I have n_digits = 0, I'm expecting the "accurate maximum number of
digits." Why is it greater than the precision reported by get_prec()?

Stepping through the program I see the following values for f internally:

64: mp = 0x0012ff3c {_mp_prec=3 _mp_size=4 _mp_exp=0 ...}
96: mp = 0x0012ff3c {_mp_prec=4 _mp_size=5 _mp_exp=0 ...}
128: mp = 0x0012ff3c {_mp_prec=5 _mp_size=6 _mp_exp=0 ...}

So does that mean what get_prec() is reporting is actually 1 limb (32 bits)
less than what's actually used?


More information about the gmp-discuss mailing list