Binary output of mpf_get_str() has too many bits?

Paul Zimmermann Paul.Zimmermann at loria.fr
Thu May 20 15:52:53 CEST 2010


       Rick,

> So what is the take home message? Is it that 'precision' number of bits are
> accurate, and that possibly a few bits beyond are as well, but not
> guaranteed?

one reason why GMP MPF class uses more bits than requested by the user is
that it uses a base 2^32 or 2^64 depending on your computer. If you want to
represent the number 1+epsilon in base 2^64, where epsilon is small, you will
realize that the most significant limb will store only one bit, that
corresponding to 1. If on the contrary you want to store 0.5+epsilon, the
most significant limb will contain 63 bits (2^63, for 0.5 with exponent -1
in base 2^64). Thus to be sure to have at least say 66 significant bits for
every number, you need at least three limbs, which will store between
129 and 192 significant bits.

Paul Zimmermann


More information about the gmp-discuss mailing list