Float Point in Binary



   IEEE single format that is 32 bits long.

  1. The most left (position 31) 1 bit is sign flag, 0 is for positive, 1 is for negative.
  2. The trailling (position 30 ~ 23) 8 bits are exponent section. The exponent value plus a bias of 127 construct this.
  3. The most right 23 bits is expressed with the leading 1 removed(Hint 1) and padding with zeros on the right


For example:

   (78.375)10 = (1001110.011)2        (Hint 2)

   = (1.001110011 * 2^6)2                (The red '1' is removed in binary representation)

Storage:
     0  10000101  00111001100000000000000

Sign flag:                   0                                                      1 bit
Exponent section:   10000101                                       8 bits
Fraction section:     
00111001100000000000000   23 bits


Hint 1: Do you know why the leading 1 is removed? Yes, we just need not to store it for any number will leading a '1' at most left bit(except zero)!

Hint 2: How to binary: From the point, grow by power of 2 if go left, grow by power of -2 if go right.

 
posted @ 2011-07-31 15:31  walfud  阅读(271)  评论(1编辑  收藏  举报