How to represent huge floating point numbers in Visual C ++

double ld = 0.299999999999999990009;

It turns out truncated to 0.29999999999999999

How to get more precision from float type?

Is there a class that wraps more meaning?

+3
source share
4 answers

The Gnu MP library obviously has support for arbitrary dimensional floating-point arithmetic. I would recommend trying it, as GMP is one of the fastest general-purpose arithmetic libraries of any size. It is very stable, has complex C interfaces, as well as C ++ wrappers and binaries compiled for many compilers.

GNU MPFR GMP , .

+7

long double, MSVS, , double ( ).

, . HPA.

+3

, . , GMP ( LGPL)

+1

double (1×10^−37 → 1×10^37),

I think it is truncated because you did not set the precision of std :: cout

#include <iomanip>
float yourfloat;
cout << fixed << setprecision(lengthoftheprecision) << yourfloat;
0
source

Source: https://habr.com/ru/post/1792642/


All Articles