Anyone familiar with GNU MP?
From C++ to PHP, debugging to webhosting; help and discussion about writing your latest program to running your website. NOT for help when your PC won't work.
| Announcements | Posted on | |
|---|---|---|
| Please change your TSR password | 23-05-2013 | |
| Enter our travel-writing competition for the chance to win a Nikon 1 J3 camera | 20-05-2013 | |
-
Re: Anyone familiar with GNU MP?What's the problem? If you can output it to std out, then what's stopping you outputting to a file instead? What are using to output it to the console?(Original post by beepbeeprichie)
I'm working on a C++ app which deals with very long floats. I'm using the GNU MP library and it outputs correctly in the console but I really need it to output to a file. Does anyone know how do this (combine ofstream and the MP lib)?
Thanks! -
Re: Anyone familiar with GNU MP?
I'm not particularly familiar with GMP, but gmp_snprintf() ought to work when used with a temporary buffer. Not elegant, but easy to code and just as fast as anything else (although really, you should just use the fprintf() functions instead of trying to channel everything through ostreams).
http://gmplib.org/manual/Formatted-O...Functions.htmlLast edited by roblee; 31-03-2012 at 14:21. -
Re: Anyone familiar with GNU MP?I think I've realised my stupid error. Whilst stdprecision (x) sets precision by number of decimal places the GNU MP precisions works by bit precision.(Original post by maturestudy)
cout << setprecision(28) << fixed << n; -
Re: Anyone familiar with GNU MP?I think it's safe to say we'd have been here a long time before I thought of that!(Original post by beepbeeprichie)
I think I've realised my stupid error. Whilst stdprecision (x) sets precision by number of decimal places the GNU MP precisions works by bit precision.