Computer Composition Principle] fixed-point arithmetic

Fixed-point addition and subtraction

Complement addition:

After complement negative number expressed as positive numbers to be processed, and

When necessary to subtract a number x when x may be combined with the corresponding negative complement [-x] instead complement

[X] [y] + Complement Complement = [x + y] Complement

Complement subtraction

[Xy] = [x] Complement Complement + [- y] Complement (mod 2)

[Xy] = [x] Complement Complement + [- y] Complement (mod n + 1 th power of 2)

Complement the basic rules:

  • Each operand operations are by complement, complement computation result is still
  • Like the sign bit and numerical bits participate in operations
  • If the sum, then the two's complement added directly, and the resulting two's complement of the number, if differencing, changed complement (complement variable [y] [-y] s) will subtrahend and minuend and It is added to obtain the difference between the two's complement of the number of
  • If you lose more than the mold

overflow:

Two positive addition result becomes negative overflow

Two addition result becomes positive negative overflows

Double the sign bit is also called deformation complement (00 11 represent positive negative) sign bit to participate in operational results appear 01 or 10 if an overflow occurs

Single sign bit: the highest value generates a carry-bit sign hardware bit an overflow MSB carry-sign bit carry generation to the next, that is, when no overflow occurs when there carry or not carry, represented by XOR them.

 

Fixed-point multiplication:

Multiplying an original code: bit value sign bit multiplication process alone

Doubling the product of the number of bits (multiplied by 4 into two 8)

Improved multiplication:

 

Guess you like

Origin www.cnblogs.com/dream-to-pku/p/11616084.html