What range of numbers can be represented in a 16-, 32- and 64-bit IEEE-754 systems?

前端 未结 7 1562
天涯浪人
天涯浪人 2020-11-22 12:20

I know a little bit about how floating-point numbers are represented, but not enough, I\'m afraid.

The general question is:

For a given preci

7条回答
  •  说谎
    说谎 (楼主)
    2020-11-22 12:42

    See IEEE 754-1985:

    v = (-1)^sign * s^(exponent-exponent_bias) * (1 + fraction)

    Note (1 + fraction). As @bendin point out, using binary floating point, you cannot express simple decimal values such as 0.1. The implication is that you can introduce rounding errors by doing simple additions many many times or calling things like truncation. If you are interested in any sort of precision whatsoever, the only way to achieve it is to use a fixed-point decimal, which basically is a scaled integer.

提交回复
热议问题