I have a "strange" behaviour with a double:
#include <stdio.h>
int main()
{
double var = 4724.735;
double var1 = 472473.5;
printf("var: %19.11f var1: %19.11f\n", var, var1);
var *= 100.0;
printf("var * 100.0: %19.11f\n", var);
return 0;
}
The result is:
var: 4724.73500000000 var1: 472473.50000000000
var * 100.0: 472473.49999999994
Why after the * 100.0 operation I have that result instead of 472473.50000000000?
With a smaller number, i.e. var = 724.735, the problem doesn't exist.
Are you sure is a duplicate? The Is floating point math broken? is related to javascript and here the problem is in the first decimal and only if I use an integer part of 4+ number. Thank you