Unsigned arithmetic
Unsigned addition
We follow the following 4 (bit addition) rules:
Overflow
Take, a -bit value, say . If we perform , we end up at since the addition has overflowed past the MSB.
Hence, this value is discarded and we are left with .
A question may specify a $n$-bit system.
**Always** pick `overflow` if you end with a carry-out, such as above.Unsigned subtraction
We follow the following 4 (bit subtraction) rules:
Before doing unsigned subtraction, always check the magnitudes of the operands.
For example, $001 - 101$, the second operand is larger than the first, hence since we are working with unsigned binary, this operation is invalid.Unsigned multiplication
To multiply two binary numbers together:
- Select the number with the least digits.
- Split the number into parts.
- Multiply each part to the other number.
- Sum resulting parts.
For example, take .
- The number we first take is .
- Split it into and .
- Take the other number and multiply by the specified power of :
- Sum the resulting parts: Hence the final answer is .
Unsigned division
Computer systems may opt for short or long division algorithms. Here is an example using long division:
Each comparison should be justified as you progress through each column: