I have a problem using GMP (floating point, etc.)

The Undertaker hui_buh666 at yahoo.de
Mon Sep 7 08:02:16 UTC 2020


Hello,
I want to divide 8 through 7 and have 150 digits after the point.
This is my code so far:


#include <iostream>#include <gmp.h>

using namespace std;

int main()
{

mpf_t x, y, z;
mpf_inits(x, y, z, NULL);

mpf_set_str(x, "8", 10);
mpf_set_str(y, "7", 10);

mpf_div(z, x, y);


mpf_out_str(stdout, 10, 150, z);
mpf_clear(x);
mpf_clear(y);
return 0;
}
Here are my questions:
1.) Is it possible to use cin and cout? And how I do that? Because I want to give input and not compile it again, after I have a result and calc the next thing.
2.) How do I use the other inits and sets? I have the problem it says failed to convert to ...
3.) My result is: 0.114285714...e1    I want it 1.1428...(with 150 digits) How I do that?
And yes I read through the manual. But I need some help.
Thank you in advance!Sebastian


More information about the gmp-discuss mailing list