title: GMP convert mpz to mpf
body: <p>I am using GMP, and I want to be able to quickly convert an <code>mpz</code> to an <code>mpf</code>. I looked through the library and couldn't find much. The best thing I could think of was this: </p>
  
  <pre><code>mpz_t x;
  /* Insert code here that assigns some value to x */
  char buf[SIZE];
  gmp_sprintf(buf, "%Zd", x);
  mpf_t y;
  mpf_set_str(y, buf);
  </code></pre>
  
  <p>This solution requires repeated conversion to and from a string. Also, it is limited by <code>SIZE</code>, and I see no way to predetermine how large <code>SIZE</code> needs to be. Is there any better way to do this conversion?</p>