Addition:
Decimal Binary
736 1001010 Here we line up the numbers
+ 44 + 11010 so the rightmost digit are lined.
1
736 1001010 Now we start at the right and add
+ 44 + 11010 the digits and move left, we
0 0 carry a digit over when needed.
1 1
736 1001010 Here we carry a number on the base
+ 44 + 11010 two addition.
80 00
736 1001010 We continue on until we get to the
+ 44 + 11010 end of all the aditions and
780 1100100 have our answer.
So addition is easy, but what about subtraction?0110 ( 6) +???? (-2) 0100 ( 4)
0110 ( 6) +1110 (-2) 10100 ( 4)
| Decimal | Binary |
|
0 -1 -2 -3 -4 -5 |
0000 1111 1110 1101 1100 1011 |
Examples:
6 = 0110 = 0110
-2 = -0010 = +1110
4 = ???? = 10100
2 = 0010 = 0010
-6 = -0110 = 1010
-4 = ???? = 1100
This is called 2s compliment math. There is also 1s compliment, but much like Octal
it is not used as often as 2s compliment or Hexidecimal. FYI 1s compliment is when
you do not add 0001 after the bit conversion, so -1 = 1110. Math is then done slightly
differently in this case but will not be discussed in these notes.
Decimal Binary
54 110
x 21 x 11
4 0
50 10
80 100
+1000 00
1134 100
+ 1000
10011
Decimal Binary
4 / 456 100 / 10101011000
1 1
4 / 456 100 / 10101011000
4 100
5 10
11 10
4 / 456 100 / 10101011000
4 100
5 101
4
16
114 101
4 / 456 100 / 10101011000
4 100
5 101
4 100
16 10
16
0
1010
100 / 10101011000
100
101
100
101
10101
100 / 10101011000
100
101
100
101
100
11
101010
100 / 10101011000
100
101
100
101
100
110
1010101
100 / 10101011000
100
101
100
101
100
110
100
100
10101011
100 / 10101011000
100
101
100
101
100
110
100
100
100
0
101010110
100 / 10101011000
100
101
100
101
100
110
100
100
100
0
Keep in mind that these things are very easy, and very mechanical. more examples will be given in labs as well.