Why can't decimal numbers be represented exactly in binary?

前端 未结 20 3412
不知归路
不知归路 2020-11-21 05:15

There have been several questions posted to SO about floating-point representation. For example, the decimal number 0.1 doesn\'t have an exact binary representation, so it\'

20条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-21 05:56

    A parallel can be made of fractions and whole numbers. Some fractions eg 1/7 cannot be represented in decimal form without lots and lots of decimals. Because floating point is binary based the special cases change but the same sort of accuracy problems present themselves.

提交回复
热议问题