Reputation: 839
Having just succeeded in compiling a program using MPFR C++ (1st time), I need to print out some fairly large numbers, but they only come out as engineering notations instead of the whole numbers. From what I read, the library is not optimized for (arbitrary) integers, so it's fine to use floating point numbers as integers, since they won't be having any decimals. I am only a beginner in C++, so I don't know my way through all the tools available, but is there a way to print out the (big) floating point numbers as if they were integers? As an example, instead of (say) 1.12276e+44
, print 112275575285571389562324404930670903477890625
. If I try std::cout.precision(44)
, I get 1.12275575285571389562324404930670903477890625e+44
, which doesn't look any better.
Upvotes: 1
Views: 1209
Reputation: 557
MPFR C++ allows precise tuning of output format a la printf
style (if standard C++ capabilities is not enough). Example:
std::cout<<x.toString("%34.0RNf")
Please refer to MPFR manual for format specification in brackets. Also you might check this question: https://stackoverflow.com/a/9627660/479995
Upvotes: 3