long double a = 497;
long double b = 951258;
long double c = 392673418417;
v = a * b * c;
when I watch the value of v, it is 185646264136289737248, why does this happen? the correct value should be 185646264136289737242.
long double a = 497;
long double b = 951258;
long double c = 392673418417;
v = a * b * c;
when I watch the value of v, it is 185646264136289737248, why does this happen? the correct value should be 185646264136289737242.
This is due to the fact that doubles can't represent all possible values. If you need that precision and you are only dealing with integers then use int
or long long int
.
If you want to know more about it you can google it or read this article.