Principles of Computer Organization - floating-point addition and subtraction

  1. The step of calculating the floating point addition and subtraction

Previously mentioned, floating point numbers are often written in the following form:
        X-Mx * = 2EX

Wherein Mx mantissa for floating point, typically less than the absolute value of the normalized fractional binary 1, the original multi-purpose machine code (or complement) in the form of FIG. Ex order code for floating-point number, usually binary integer machine with multiple shift (or complement) that is a power of a given index, the index is used while the bottom 2, 8 or 16, here first 2 is a bottom discussed as an example.

The step of calculating the floating point addition and subtraction
  assuming two floating point numbers
     X = Mx * 2Ex, Y = My * 2Ey

1. To achieve X ± Y operation, use the following five steps:
  (1) the order of the operation, i.e., the size of the exponent values of the two floating point compare seeking △ E = Ex-Ey.. When it is not equal to zero, that the first two should take the same number of exponent values. This is accomplished by the original order code number smaller mantissa right | △ E | bits, plus its order code value | △ E |, i.e., a right to make every mantissa exponent plus 1, the floating-point number the value of the constant (but the accuracy is worse). When mantissa right, ending the original code in the form of sign bits do not participate shift, ending up high 0; mantissa to complement the form of the sign bit to participate in their own right and remains unchanged. To minimize these errors, the available
  additional lines, high retention values lost during the right one to several bits, rounding for later use.

(2) achieve mantissa increase (decrease) operation of the floating point summation is performed after step (difference) of the two operations is completed.

(3) is normalized, if the result does not satisfy the normalization rules, it is necessary to turn it into a normalized number, the double complement sign bit mantissa, it must be 001 ×× ... × or
 
  110 × × ... × form. Here normalization processing rule is:
  When the value of two symbol bits of the mantissa of the result is not the same, indicating that an overflow of the mantissa. At this time, the result should be a right mantissa, exponent and added to the value 1, which is referred to as normalized to the right, referred to as the right regulation.

When the operation result does not overflow mantissa, but the maximum value and the sign bit with the bit value indicating standardized rule is not satisfied, then repeat the mantissa should be left, and reduction stage 1, until at the highest numerical value of the bit different from the value sign bit is reached, which is left normalized operation, referred to as the left rules.

(4) rounding. When performing operations on the right order or regulation, will make ending in one or more of the value on the low is definite displacement, the numerical accuracy is affected, it can save a few high-value definite displacement of rounding up for use . The general principle is to have rounded into homes there, and try to make the rounds and equal opportunities, in order to prevent the accumulation of error. Common approaches "0" homes "1" into the process, i.e., the most significant bit is definite displacement of the last bit in the mantissa adding 1:01; definite displacement value is 0 is discarded. Maximum error of the program is 2- (n + 1). This may in turn make mantissa overflow, then we should do it again the right regulation. Another method of "set" method, that is, the right, the value of the lost original low removed, and the results into a lowermost position. The program also has the result that the mantissa becomes larger or smaller two possibilities. That is the lowest bit mantissa before rounding has been zero, so that it becomes 1 for a positive number, the larger the value, equal to a least significant bit into the 1. If the lowest bit mantissa is 1, then re-set its no practical effect, give it a loss equal to the low value of the mantissa.

(5) allow the correct results, i.e., to check whether the exponent overflow. Floating-point overflow its exponent overflow is manifested. Before adding and subtracting the real end, to check whether an overflow, if the normal order code, plus (minus) the end of normal operation; if exponent underflow, floating point computation result is set to a machine in the form of zero, if the overflow, the overflow flag is set.

FIG normalized floating-point addition and subtraction process 2.21

See Examples of a floating point adder.
  Assumed that X = 2010 * 0.11011011, Y = 2100 * (-0.10101100) of the floating-point representation thereof respectively
         order number order code symbol character mantissa
     [X] Floating 11011011 00 010 = 00.
     [the Y] = 00 in the floating 1001101010100
           complement complement

X + Y process is performed as follows:
  (1) Find the order of the step difference and
   △ E = Ex-Ey = [ Ex] Floating + [- Ey] Floating = 00,010 + 11,100 = 11,110 i.e., △ E -2,
the small exponent X, Mx should be shifted two bits, Ex 2 was added to give [X] = 00 in the floating 100,000,011,011,011

(2) sum mantissa
     0000110110
    + 11 01010100
    
     1110001010 (3) is normalized
  symbol bit value of the bit with the highest value of the result of the processing to be executed left rules, the result is 110001010110, order code 00011.

(4) The rounding processing
  a processing method using the 0 homes, there are
     1,100,010,101
    + 1
    
     . 11 00.01011 million

(5) the overflow determination
  step 00. code symbol does not overflow bit, so as to obtain a final result X + Y = 2011 * (- 0.11101010)

When the mantissa is represented by complement, should meet the normalized floating point mantissa bits with the highest number of different sign bit, the same is not satisfied as normalization.

(6) represents the mantissa, after addition / subtraction operation, the following six cases may occur, i.e., the sign bit double code
① XX ... X 00.1
② 11.0 XX ... X
③ 00.0 X XX ...
④ 11.1 X XX ...
⑤ 01. ... the X-xxx
⑥ 10.xxx ... on the X-①, ② case, meet the definition of normalized number, it is normalized numbers. The first ③, ④ case is not a normalized number, it is necessary to normalize the mantissa left to achieve, this process is called left regulation. End of
floating point operations of normalized
floating-point math normalized
normalized floating-point operations are
per one left, corresponding exponent is decremented by 1 until it reaches a normalized number.
Left regulation can be repeated.

The first ⑤, ⑥ overflow condition is called the point addition and subtraction, but not in the floating-point addition and subtraction, only that this time the absolute value of the mantissa is greater than 1, and not a real overflow. Ending in this case should be shifted to the right in order to achieve normalization. This process is called the right regulation. Mantissa right one each, plus an appropriate order code.
Right up to regulation only once.

Summary: Left regulatory process, the number to the left of the decimal point in time to go, order code -1, the right regulatory and vice versa.

Guess you like

Origin blog.csdn.net/weixin_43752167/article/details/91385263