IEEE 784 : Floating Point Representation


Floating Point Representation:

A floating point number is typically represented in binary as:

Sign bit
Biased-Exponent
Mantissa

Where,

·         Sign bit tells whether the number is positive or negative
For positive, sign bit=0
For negative, sign bit=1
·         Biased Exponent is a special integer which is added or subtracted from the exponent as described further.
·         Mantissa contains fraction part.

Typically in a computer, the size of each of these components are fixed.

Now, let us have a formal description of such numbers.

Let us consider a computer architecture which supports
·                     Sign bit of 1 bit
·                     Biased Exponent of 8 bits
·                     Mantissa of 23 bits

Hence,
            Total size=23+8+1=32-bits.
NOTE:
This configuration is a standard configuration and is typically known as IEEE-784 standard

Now, let us take an example and try to understand how it is represented.

For example, suppose we want to represent number 1234.625 into IEEE-784 standard.
To convert it following steps is followed.

STEP 1:
            Express the number purely in decimal i.e. without any exponent part.
            For e.g. if the number is 12.34*103 then the number is represented as 12340.

            Then,
Convert the given number into its binary equivalent.
Hence, (1234.625)10 = (0100 1101 0010.1010)2
STEP 2:
            Now normalize the number.
            Number (0100 1101 0010.1010)can be normalized as (1.0011 0100 1010 1000*210)2
STEP 3:
            Compute the biased exponent. The biased exponent is computed as
            For a representation, if exponent bit is represented in e bits.
            Then biased exponent will be
2e-1-1
            For IEEE-784,
Biased exponent is
28-1-1, as e=8-bits
Biased exponent = 127
After computing the biased exponent, add this value to the exponent part of your number. Here,
Exponent is 10,
Hence biased exponent is 127+10=137
Convert the biased exponent to its binary equivalent
137 = 1000 1001
STEP 4:
            Depict it,

0
1000 1001
0011 0100 1010 1000 0000 000



Similarly, a given floating point number can be tracked down to its decimal equivalent.
For example,
                                          
0
1000 1001
0011 0100 1010 1000 0000 000
 Hence it is written as,
Firstly, the biased exponent is handled by subtracting the biased number from it.
Hence,
1000 1001 = 137
So, 127 is subtracted from 137.
Hence,
137-127 = 10
So, the given number is
1.0011 0100 1010 1 *210  = (0100 1101 0010.1010)2
Now, get its decimal equivalent,
Which is 1234.625

A general discussion on FLOATING POINT numbers


Sign
Biased Exponent
Fraction
Value
Positive zero
0
0
0
0
Negative Zero
1
0
0
-0
Plus Infinity
0
255 ( all 1s)
0
Minus Infinity
1
255 ( all 1s)
0
-∞
Not a Number (NaN)
0 or 1
255 ( all 1s)
Not equal to 0
NaN

With these restriction, there exists numbers which can’t be represented.
Let us try to compute these different boundaries,
Range of expressible positive numbers,

Let us consider a computer architecture which supports
·                     Sign bit of 1 bit (s = 1)
·                     Biased Exponent of 8 bits (e = 8)
·                     Mantissa of 23 bits (m= 23)


The maximum positive number expressible will be,

0
1111 1110
11111111111111111111111

Now, interpret this number,

Biased exponent is 2e-1-1 = 127
Let say this number to be k,
Hence k=127
Now (1111 1110) = (254)
Hence our exponent is 254-k=254-127=127
Hence our number is,
1.11111111…1 * 2127
Which can be written as,

1 followed by 23 1s and then followed by 104 0s, which is
1 11111111111111111111111 0000000000…0
( 104 zeros)
Now convert it into decimal, it would be
1*2104 + 1*2105 + 1*2106 +…+ 1*2127
=3.4028*1038

 

Comments

  1. Is this supposed to be referring to IEEE 754? I don't think 784 exists.

    ReplyDelete
  2. Replies
    1. Do you have a link to somewhere that confirms that it does exist please? Google finds only this post, for me anyway.

      Delete
    2. Sorry my bad. It`s referring to IEEE 754 as You wrote earlier. My bad. >.<

      Delete

Post a Comment