Number of significant digits for a floating point type

前端 未结 4 1717
梦谈多话
梦谈多话 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:30

    The problem here is that you cannot assure a number can be stored in a float. You need to represent this number with mantissa, base and exponent as IEEE 754 explains. The number printf(...) shows you is the real float number that was stored. You can not assure a number of significant digits in a float number.

提交回复
热议问题