Number of significant digits for a floating point type

mk_ picture mk_ · Oct 10, 2012 · Viewed 22.3k times · Source

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?

Answer

CrazyCasta picture CrazyCasta · Oct 10, 2012

6 significant digits means that the maximum error is approximately +/- 0.0001%. The single float value actually has about 7.2 digits of precision (source). This means that the error is about +/- 12345.6/10^7 = 0.00123456. Which is on the order of your error (0.000391).