Introduction
Summary
keywords
TODO
HW
Exercise*
Next time
Arithmetic w/ Unsigned Numbers
Addition
- add bit-wise.
- if there's carry-out, you add 1 to the next digit.
Subtraction
- borrow values from bigger digits, and subtract.
- This is so complex. Just use signed number arithmetic and convert back.
Multiplication
- add each multiplication to each digit.
- Just like we learned in elementary school.
Arithmetic w/ Signed Numbers
Addition
- The system is well defined, so you just need to calculate bit-wise.
Problems
- When (positive)+(negative) makes additional digit carry out, you discard it.
- When (positive) +(positive) makes additional digit carry out, it is an overflow.
- When (negative) + (negative) makes sign digit into positive, it is an underflow.
- In either way, overflowed number can't be represented in bit limitation.
How do you handle overflow/underflow?
- This problem also easily happens in multiplications.
- How to handle? just use additional 1 bit more for error catching.
(ONLY FOR 2's complement) Sign extension might handle it.
- the sign-bit should be replicated for n more digits in front.
Subtraction
- take the 2's complement of the subtrahend(latter value) and add it.
- discard any final carry bit.
Binary Codes & its arithemetics
It is not defined mathematically.
-
It is just a set of numerical information.
-
It's a pattern of numerical representation of another element of information.
-
Packed representation is bit-inefficient.
Addition
THOUGH it is not defined mathematically, it mimicks a sequence of natural numbers. So a psudo-addition is possible.
If the sum is smaller than 10, the result is correct. If the sum is bigger than 9, since we don't use 10~15 reprentations, we need to skip 6 representation and get the next representation. That is numerically equivalent to "adding 0110" more.