Number of significant digits for a floating point type

前端 未结 4 1716
梦谈多话
梦谈多话 2020-12-05 20:51

The description for type float in C mentions that the number of significant digits is 6. However,

float f = 12345.6;
4条回答
  •  时光说笑
    2020-12-05 21:32

    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).

提交回复
热议问题