0
float y=98.7654;
printf("%f\n", y);

This is giving the output as 98.765404. I cannot understand how the output ends with 04, can anybody please explain it?

ForceBru
  • 43,482
  • 10
  • 63
  • 98
  • In C, `98.7654` is a double and the line `float y = 98.7654;` converts the double to float. Try either `float y = 98.7654f;` or `double y = 98.7654;`. – ssd Oct 20 '20 at 18:29
  • @ssd: `float y = 98.7654f;` will have the same result as `float y = 98.7654;`. – Eric Postpischil Oct 20 '20 at 18:35

0 Answers0