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

前端 未结 7 1556
天涯浪人
天涯浪人 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:40

    First off, neither IEEE-754-2008 nor -1985 have 16-bit floats; but it is a proposed addition with a 5-bit exponent and 10-bit fraction. IEE-754 uses a dedicated sign bit, so the positive and negative range is the same. Also, the fraction has an implied 1 in front, so you get an extra bit.

    If you want accuracy to the ones place, as in you can represent each integer, the answer is fairly simple: The exponent shifts the decimal point to the right-end of the fraction. So, a 10-bit fraction gets you ±211.

    If you want one bit after the decimal point, you give up one bit before it, so you have ±210.

    Single-precision has a 23-bit fraction, so you'd have ±224 integers.

    How many bits of precision you need after the decimal point depends entirely on the calculations you're doing, and how many you're doing.

    • 210 = 1,024
    • 211 = 2,048
    • 223 = 8,388,608
    • 224 = 16,777,216
    • 253 = 9,007,199,254,740,992 (double-precision)
    • 2113 = 10,384,593,717,069,655,257,060,992,658,440,192 (quad-precision)

    See also

    • Double-precision
    • Half-precision

提交回复
热议问题