Alex Rivera | Logout

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

Asked 2009-05-16T14:37:41.893
91

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).

Edit
Report

2 Answers

126

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 solutions to the following:

If you want an accuracy of +/-0.5 (or 2^-1), the maximum size that the number can be is S1. Any larger than this and the distance between floating point numbers is greater than 0.5.

If you want an accuracy of +/-0.0005 (about 2^-11), the maximum size that the number can be is S4. Any larger than this and the distance between floating point numbers is greater than 0.0005.

answered 2009-05-16T16:30:44.070
20

The precision quoted form Peter R's link to the MSDN ref is probably a good rule of thumb, but of course reality is more complicated.

The fact that the "point" in "floating point" is a binary point and not decimal point has a way of defeating our intuitions. The classic example is 0.1, which needs a precision of only one digit in decimal but isn't representable exactly in binary at all.

If you have a weekend to kill, have a look at What Every Computer Scientist Should Know About Floating-Point Arithmetic. You'll probably be particularly interested in the sections on Precision and Binary to Decimal Conversion.

answered 2009-05-16T16:15:05.293

Your Answer