I have a long double
variable and I noticed that for really big numbers I get a numeric error. Small reproducible example:
#include <iostream>
using namespace std;
int main()
{
std::cout.precision(64);
long double value = 45;
long double d = 39353425746711768;
long double factor = 622;
value += (d * factor);
std::cout << value << std::endl;
return 0;
}
I get the following result:
24477830814454719740
But:
45 + 39353425746711768 * 622 = 24477830814454719741
How can I get 24477830814454719741
? Does there any hidden conversions being made by CPP?