Wednesday, May 21, 2008

Mechanics' Floating Point revealed

The eight bits in the pattern are used as follows:

S EEE MMMM

S is the "sign bit": 1 means negative, 0 means positive.

EEE are the "exponent": in "excess four" notation, meaning that the usual decimal interpretation of these bits is four more than the actual power of two. When all 8 bits are 0 the entire bit pattern represents the number zero. 001 means an exponent of -3 (i.e. a multiplier of 1/8), 010 mean -2, and so on, up to 111 which means an exponent of 3 (i.e. a multiplier of 8).

MMMM are the "mantissa": the fractional value which is multiplied by two to the exponent value. There is assumed to be a decimal point and a "1" bit to the left of MMMM. So, the pattern 0000 represents the fraction .10000 (i.e. 1/2). Similarly, the pattern 0001 represents the fraction .10001 (i.e. 17/32), and on up to 1111, which represents the fraction .11111 (i.e. 31/32).

In the table below, the exponent bit patterns label each of the columns. There are only 7 patterns because the bit pattern 000 means that the entire number is zero. This wastes some of the bit patterns because the entire 8 bits represent zero whatever bit patterns are present in the S and MMMM bit positions.

The mantissa bit patterns label each of the rows.

Each cell of the table shows the real number represented by the overall 8 bit pattern. Not shown are the negative numbers, which use the same bit pattern except for the sign bit.


This table can also be found at http://sanbachs.net/mfp/mfp.html.

2 comments:

Myrna said...

Okay, this is starting to lose me...

Nancy said...

I was already lost :)