floating-pointprecisionnumericalieee-754

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


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 precision (for my purposes, the number of accurate decimal places in base 10), what range of numbers can be represented for 16-, 32- and 64-bit IEEE-754 systems?

Specifically, I'm only interested in the range of 16-bit and 32-bit numbers accurate to +/-0.5 (the ones place) or +/- 0.0005 (the thousandths place).


Solution

  • For a given IEEE-754 floating point number X, if

    2^E <= abs(X) < 2^(E+1)
    

    then the distance from X to the next largest representable floating point number (epsilon) is:

    epsilon = 2^(E-52)    % For a 64-bit float (double precision)
    epsilon = 2^(E-23)    % For a 32-bit float (single precision)
    epsilon = 2^(E-10)    % For a 16-bit float (half precision)
    

    The above equations allow us to compute the following: