two questions on GMP & C float

Torbjorn Granlund tg at
Fri May 15 19:22:16 CEST 2009

Vojtěch Bubník <bubnikv at> writes:

  We are using GMP extensively for our geometric calculations like
  intersection lines between two 3d meshes etc. I am combining boost
  interval arithmetics with GMP to speed up predicates. That works
  really well. The interval arithmetics library is switching FPU
  rounding mode down. Does GMP use FPU or may I leave rounding mode set
  to "down" for the interval arithmetics library to work even during
  calls to GMP?

GMP hardly uses the FPU at all.  Except for some processors, like
UltraSPARC.  But I believe the FPU dependent code in GMP is rounding
mode resilient.

  Another question. If I know beforehand that the floats I am converting
  to mpq have some right mantissa bits cleared, will the mpq numbers be
  faster? Will the mpq representation use less bits? Will it help, if I
  write my own conversion function from float with limited mantissa to
GMP conversion routines will find the smallest fraction the accurately
represents your float.  I.e., it will find a n/d fraction were (n,d)=1.


More information about the gmp-discuss mailing list