"mpf_t floats have a variable precision mantissa ..."

Torbjorn Granlund tg at swox.com
Fri Jan 23 14:05:51 CET 2009


"Bruce M. Axtens" <bruce.axtens at gmail.com> writes:

  The question I _meant_ ask concerned the mantissa, not the exponent, and 
  has lots to do with the question I asked earlier in the week regarding 
  "missing" digits on the sum of two negative floats.
  
  Given that the mantissa has a variable precision, how does one tell if 
  one has overflowed the mantissa's current precision setting? Or, from 
  the proactive side, how can one tell if mantissa precision overflow is 
  likely?
  
Oh, this is someting quite different.

You would like some measurement of cancellation of mantissas.

Any answer would be quite comlicated, but a short answer might be "don't
user floating point if this is a concern".  It is inaccurate per
definition.

One might consider making a set of floating point operation functions
that return the number of cancelled bits.  For operations with
same-precision values (IEEE double, or mpf/mpfr with only same-precision
variables) only one variable will get cancellation (I think), but for
mpf/mpfr, we might have a destination variable that asks for much less
bits than are present in either variable.  I don't know how useful this
will be.

An alternative might be to define a new mpf2_t type and a set of
operations on it, defined such that operations are always exact, without
rounding.  Of one adds 1e999999999 and 1e-999999999, the destination
variable will contain 1e999999999 + 1e-999999999 (and use up a lot of
space!).  The only rounding should be explicit, mpf2_round(x,nbits).

-- 
Torbjörn


More information about the gmp-discuss mailing list