Documente Academic
Documente Profesional
Documente Cultură
[4]
Page | 1
Binary Arithmetic
Computer circuits do not process decimal numbers; they process binary
numbers .Therefore, we are going to learn binary arithmetic. Binary
addition is the key to binary subtraction, multiplication and division. So
let us see rules for binary addition:
1- Binary Addition
Example: Add(11)
2
to (11)
2
?
Sol:
1 carry
11 3
+ 11 + 3
110 6
Example: Add (28)
10
and (15)
10
in binary?
A B Sum Carry
0 + 0 0 0
0 + 1 1 0
1 + 0 1 0
1 + 1 0 1
Digital logic cct. Lec.[4]
Page | 2
Sol:
(28)
10
=
(11100)
2
(15)
10
=(1111)
2
1 1 carry
11100 (28)
10
+
01111 (15)
10
101011 (43)
10
2- Binary Subtraction
A B Difference Borrow
0 - 0 0 0
0 - 1 1 1
1 - 0 1 0
1 - 1 0 0
2 28 0 (LSB)
2 14 0
2 7 1
2 3 1
2 1 1(MSB)
2 0
2 15 1(LSB)
2 7 1
2 3 1
2 1 1(MSB)
0
Digital logic cct. Lec.[4]
Page | 3
Example: Perform subtraction of the binary numbers (11)
2
and (01)
2
?
Sol.
11 3
- 01 - 1
10 2
3- Binary Multiplication
A B Result
0 0 0
0 1 0
1 0 0
1 1 1
It involves forming partial products, shifting each successive
partial product left one place and then adding all the partial products.
Example:
11 3
11 3
11 9
+11
1001
Digital logic cct. Lec.[4]
Page | 4
Example:
111 7
101 5
111 35
000
+111
100011
4-Binary Division
This operation follows the same procedure as division in
decimal number system.
Example: Find (62)?
Sol.
Digital logic cct. Lec.[4]
Page | 5
Complements
In digital computer s to simplify the subtraction operation and for
logical compliments are used. There are two types of complements for
each radix system diminished radix compliment. The first is referred to
as a (r)s complement and the second as the (r-1)s compliment. For
example; in binary system we substitute base value 2 in place of (r) to
refer compliment as (2s) compliment and (1s) compliment. In decimal
number system, we substitute base value 10 in place of (r) refer
compliment as (10s) compliment and (9s) compliment.
1- 1s Complement representation of Binary Numbers
The l's complement of a binary number is found by changing all 1s
to 0s and all 0s to 1s, as illustrated below:
10110010 Binary number
01001101 1s complement
Ex (1): find 1s compliment of (1101)
2
?
Sol.
1 1 0 1 number
0 0 1 0 1s compliment
Ex (2): find 1s compliment of (1011 1001)
2
?
Sol.
1 0 1 1 1 0 0 1 number
0 1 0 0 0 1 1 0 1s compliment
Digital logic cct. Lec.[4]
Page | 6
Page | 7
first inverting each bit (taking the l's complement) and then adding
1 to the l's complement with an adder circuit.
To convert from a l's or 2's complement back to the true
(uncomplemented) binary form, use the same two procedures
described previously. To go from the ls complement back to true
binary, reverse all the bits. To go from the 2's complement form
back to true binary, take the 1's complement of the 2's complement
number and add 1 to the least significant bit.
Fig.(2) Example of inverters and adder used to obtain the 2s
complement of a binary number
Digital logic cct. Lec.[4]
Page | 8
1s compliment subtraction
Subtraction of binary numbers can be accomplished by the direct
method by using the 1s compliment method, which allows performing
subtraction using only addition. For subtraction of two numbers we have
two cases:
Subtraction of smaller numbers from larger number.
Subtraction of larger numbers from smaller number.
Subtraction of smaller number from larger number method:
1. Determine the 1s compliment of the smaller number.
2. Add the 1s compliment to the larger number.
3. Remove the carry and add it to the result.
This is called end-around carry.
Example: Subtract (101011)
2
from (111001)
2
using 1s compliment
method?
Sol.
111001
+
010100 1s compliment of 101011
(1) 001101
+1
001110 Final answer
Digital logic cct. Lec.[4]
Page | 9
Page | 10
Page | 11
Signed Numbers
Digital systems, such as the computer, must be able to
handle both positive and negative numbers. A signed binary number
consists of both sign and magnitude information. The sign indicates
whether a number is positive or negative, and the magnitude is the value
of the number. There are three forms in which signed integer (whole)
numbers can be represented in binary: sign-magnitude, l's
complement, and 2' complement. Of these, the 2's complement is the
most important and the sign-magnitude is the least used.
The Sign Bit
The left-most bit in a signed binary number is the sign bit, which
tells you whether the number is positive or negative. A 0 sign bit
indicates a positive number, and a 1 sign bit indicates a negative
number.
A 0 sign bit indicates a positive number, and a 1 sign bit
indicates a negative number.
B
7
B
6
B
5
B
4
B
3
B
2
B
1
B
0
Sign Magnitude
Sign-Magnitude Form
When a signed binary number is represented in sign-magnitude,
the left-most bit is the sign bit and the remaining bits are the
magnitude bits. The magnitude bits are in true (uncomplemented)
binary for both positive and negative numbers. For example, the
decimal number +25 is expressed as an 8-bit signed binary number
using the sign-magnitude form as 00011001.
Digital logic cct. Lec.[4]
Page | 12
Page | 13
Solution:
First, write the 8-bit number for +39 is (00100111)
2
In the sign-magnitude form, -39 is produced by changing the sign
bit to a 1 and leaving the magnitude bits as they are. The number is
10100111
In the 1s complement form, -39 is produced by taking the ls
complement of +39 (00100111).
11011000
In the 2's complement form, -39 is produced by taking the 2's
complement of +39 (00100111) as follows:
11011000 1's complement
+ 1
11011001 2's complement