integer part of an mpf number

Patrick Pelissier patrick.pelissier at gmail.com
Sat Mar 3 22:03:36 CET 2007


Hi,

 mpz_set_f should be what you want.

 - Function: void mpz_set_f (mpz_t ROP, mpf_t OP)
     Set the value of ROP from OP.

     `mpz_set_d', `mpz_set_q' and `mpz_set_f' truncate OP to make it an
     integer.

--
 Sincerely,
  Patrick Pelissier

On 3/3/07, Helmut Jarausch <jarausch at skynet.be> wrote:
> Hi,
>
> I'm new to gmp and I couldn't find a means
> to get the integer part of a long float (mpf) number.
> Something like a cast  (mpz_t)( an_mpf_variable)
>
> There must be something like this (I'd like to use this
> to get a rational approximation with a given maximal length
> of the denominator)
>
> Many thanks for a hint,
>
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss
>


More information about the gmp-discuss mailing list