c - GMP convert mpz to mpf -


I am using GMP, and I am using a mpz with a MPF < / Code>. I looked through the library and could not find much. The best thing I could think was:

  mpz_t x; / * Insert a code here which specifies the value for x * / four buffs [size]; Gmp_sprintf (buf, "% zd", x); Mpf_t y; Mpf_set_str (y, buff);  

This solution requires a string and repeated conversion from it. Also, it is limited by SIZE , and I have no way of deciding that large SIZE needs to be done is a better way of converting it ?

mpf_set_z (mpf_set rp, mpz_t op) ?

In addition to this (I think that you have done this) your MPG and MPF variables are mpf_init (mpf_t x) and Mpz_init (mpz_t x) .

Then you will do this:

  mpz_t x; Mpz_init (x); / * Insert here some values ​​that are x * / mpf_t; Mpf_init (y); Mpf_set_z (y, x);  

Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -