Complement Arithmetic in a Nutshell
Unsigned numbers:
Subtraction:
Two's complement:
- Add the complement of the subtrahend to the minuend.
- If a carry is produced, make the result negative and
take the complement of the difference to determine the
absolute value.
One's complement:
- If a carry is produced, add it to the result.
Signed Numbers:
Signed Two's complement:
Addition:
Add both numbers.
If a carry is produced, drop it.
The result will be in signed two's complement form
Subtraction:
Add the minuend to the complement of the subtrahend.
If a carry is produced, drop it.
|
|
|
Overflow:
Occurs when result requires more bits than the number format can
store,
i.e., the addition of two unsigned 4-bit numbers can result in a 5-bit
number (indicated by a carry out):
With signed numbers, overflow is indicated when the carry
into the
Most significant (leftmost) bit position and out of the MSB
position are different.
For instance, consider the addition of the following 2 6-bit signed
numbers:
File translated from TEX by TTH,
version 0.9.
|