mpf_get_str

Torbjorn Granlund tg at gmplib.org
Sun Oct 6 14:04:32 CEST 2013


Adam <adammaj1 at o2.pl> writes:

  Hi.
  I try to convert decimal fration to binary using mpf_get_str .
  Example input 1/6 should give 0.00101010101010101
  
  How can I do that using gmp ?
  Below is my program.
  it gives :
  101010101010101010101010101010101010101010101010101010101010101011
    exponent : -2
  
In what way are you discontent with the result?

(If you really just want around 16 binary places, mpf cannot be used.
You may want to look at the mpfr library instead.)

-- 
Torbjörn


More information about the gmp-discuss mailing list