For example if double a = 34.837864
and float b = (float)a
why does b
have different decimals if b
is in the range of float?
Or in this other example:
float a = 3.38776326737464747726337264343434334434343;
double b = 3.38776326737464747726337264343434334434343;
printf("%.16f\n%.16lf",a,b);
The output is a=3.3877632617950439
and b=3.3877632673746474
. We can see that there are some decimals that are different.
Why does the output has different decimals if both of them are printing the same number and this number is in the range of float and double?