Hello all. I am trying to add an int to a float. My code is:
int main() {
char paus[2];
int millit = 5085840;
float dmillit = .000005;
float dbuffer;
printf("(float)milit + dmillit: %f\n",(float)millit + dmillit);
dbuffer = (float)millit + dmillit;
printf("dbuffer: %f\n",dbuffer);
fgets(paus,2,stdin);
return 0;
}
The output looks like:
(float)millit + dmillit: 5085840.000005
dbuffer: 5085840.000000
Why is there a difference? I've also noticed that if I change dmillit = .5, then both outputs are the same (5085840.5), which is what I would expect. Why is this? Thanks!