IEEE Floating-Point

IEEE 754 was an industry standard for representing floating-point numbers in computers. It was the most widely used format for floating-point computation. It was implemented in software, in the form of floating-point libraries, and in hardware, in the instructions of many CPUs

IEEE 754 represents numbers in binary, providing definitions for four levels of precision, of which the two most commonly used are

Level | Width | Range at full precision | Precision |
---|---|---|---|

Single precision | 32 bits | ±1.18×10^{−38} to ±3.4×10^{38} | Approximately 7 decimal digits |

Double precision | 64 bits | ±2.23×10^{−308} to ±1.80×10^{308} | Approximately 16 decimal digits |

Floating-point numbers in IEEE 754 format consist of three fields: a sign bit, a biased exponent, and a fraction. The following example illustrates the meaning of each

The decimal number 0.1562510 represented in binary is 0.00101_{2}Analogous to scientific notation, where numbers are written to have a single non-zero digit to the left of the decimal point, we rewrite this number so it has a single 1 bit to the left of the "binary point". We simply multiply by the appropriate power of 2 to compensate for shifting the bits left by three positions:

0.00101_{2} = 1.01_{2} X 2^{-3}

Now we can read off the fraction and the exponent: the fraction is .012 and the exponent is −3

The three fields in the IEEE 754 representation of this number are:

sign = 0, because the number is positive. (1 indicates negative.)

biased exponent = −3 + the "bias". In single precision, the bias is 127, so in this example the biased exponent is 124; in double precision, the bias is 1023, so the biased exponent in this example is 1020.

fraction = .01000…_{2}