Operations On Numbers
Operations On Numbers
Binary Addition
• Binary addition is very simple.
• Same rule as decimal
+ 0 1
0 0 1
1 1 10
1 11 1 1 1 carries
11 1 1 0 1
+ 1 0 1 1 1
---------------------
1 0 1 0 1 0 0
Multiplication of Binary numbers
• Much the same as decimal multiplication,
except that the multiplication operations
are much simpler…
1 0 1 1 1
* 0 1 X 1 0 1 0
-----------------------
0 0 0 0 0 0 0 0
1 0 1 1 1
1 0 1 0 0 0 0 0
1 0 1 1 1
-----------------------
1 1 1 0 0 1 1 0
Complements
• Common use of complement: subtraction
operation.
• Perform subtraction through the addition
operation.
M = 03250
10’s complement of N = + 27468
------------
30718
Since N is > M the result is:
- (10’s complement 30718) =-69282
Unsigned Example #2:
• Perform the operation using 2’s
complement: 1010100 - 1000011
Solution:
X = 1010100 = 101 0100 (copy)
- Y = 1000011 =+ 011 1101 (2’s)
1 001 0001
- 1 000 0000
001 0001
Signed Binary Numbers
• 01001 can be considered unsigned
binary = 9 or signed binary = +9
Example: 1 carry
59 0101 1001
+ 39 0011 1001
----------------
1001 0010
0110 (+6)
----------------
1001 1000 (98)
BCD Addition
1 1 carry
98 1001 1000
+ 89 1000 1001
---------------
1 0010 0001
+ 0110 0110 (+6 6)
---------------
1 1000 0111 (187)
Character Representation
• ASCII – American Standard Code for
Information Interchange
00 00000000 NULL
07 00000111 Bell
09 00001001 Horizontal tab
0A 00001010 Line feed