mpf_t integer/fraction separation (real modulus)

Jim White mathimagics at
Mon Sep 26 00:32:41 CEST 2005

Following a floating-point division, I want the result
separated into integer and fractional parts.  I'm
currently using a method by which I construct my own
pair of mpf_t's from a source operand but surely there
must be an easier way?

The mpf_get_si routine is no good to me as the integer
part of the division result I want can be more than 1
limb in size.

The application is simple, and not uncommon - I want
to reduce a possibly huge number modulo 2pi. So I need
to get the integer division result, so I can multiply
that by 2pi and subtract to get the reduced "modulo
2pi" value.

Is there an easy way to do this without resorting to
low-level or custom routines?

Jim White

More information about the gmp-discuss mailing list