The description for type float in C mentions that the number of significant digits is 6. However,
float f = 12345.6;
and then printing it using printf() does not print 12345.6, it prints 12345.599609. So what does “6 significant digits” (or “15 in case of a double“) mean for a floating point type?
According to the standard, not all decimal number can be stored exactly in memory. Depending on the size of the representation, the error can get to a certain maximum. For
floatthis is0.0001%(6 significant digits =10^-6=10^-4 %).In your case the error is
(12345.6 - 12345.599609) / 12345.6 = 3.16e-08far lower than the maximum error for floats.