Friday 26 October 2012

ARITHMETICS FOR COMPUTER: FLOATING-POINT REPRESENTATION


-Representation for non-integral numbers
-Including very small and very large numbers
-123,000,000,000,000 can be represented as 1.23 x 1014and 0.0000000000000123 can be represented as 1.23 x 10-14
-What we have done, in effect, is dynamically to slide the decimal point to a convenient location and use the exponent of 10 to keep track of that decimal point. This allows a range of very large and very small numbers to be represented with only a few digits.
-In binary

To store a number in floating point representation, a computer word is divided into 3 fields, representing the sign, the exponent E, and the significand m respectively.
-Example:
       0.110 x 25
0.0110 x 26
110 x 22

-The IEEE standard has three very important requirements:
l  consistent representation of floating point numbers across all machines adopting the standard
l  correctly rounded arithmetic (to be explained in the next section)
l  consistent and sensible treatment of exceptional situations such as division by zero (to be discussed in the following section).

IEEE Floating-Point Format


}  S: sign bit (0 Þ non-negative, 1 Þ negative)
}  Normalize significand: 1.0 ≤ |significand| < 2.0
      Always has a leading pre-binary-point 1 bit, so no need to represent it explicitly (hidden bit)
      Significand is Fraction with the “1.” restored
}  Exponent: excess representation: actual exponent + Bias
      Ensures exponent is unsigned
      Single: Bias = 127; Double: Bias = 1203

Example:
1) Represent -14.375
  • Convert to binary number: 1110.0112
  • 1110.0111.110011x 23
  • Sign = 1 (negative number)
  • Exponent = 3
  • bias = 28  1 = 127 (8-bit exponent encoding for binary 32)
          adding this to the exponent gives:
          3+127=130= 100000102 
  • Mantissa = 110011 (fractional part to the right of the decimal point)
     SIGN
     EXPONENT
    MANTISSA 
    10000010 
    11001100000000000000000 
2) Represent 11000000101100110...002



No comments:

Post a Comment