Rules of BinarySubtraction
0 - 0 = 0
0 - 1 = 1, and borrow 1 from the next more significant bit
1 - 0 = 1
1 - 1 = 0
Just like subtraction in any other base
10110
-10010
00100
6
Binary Subtraction
7.
.00110011 51
- 0001011022
7
Binary Subtraction – Examples
And when a borrow is needed. Note that the
borrow gives us 2 in the current bit position.
Try out these subtractions:
2
0
0001
00011101 29
Exercise:
0 2
1.2
0.2
00011101 29
00011101 29
9
Unsigned Integers: Unsigned integer is either
positive or zero value of an integer.
Example : The number of integers between
0 and +127
Signed Integer: signed integer is either negative
value or positive value of the integer.
Example : The number of integers between
-127 and +127
There are many schemes for representing
negative integers with patterns of bits.
Unsigned and Signed Integers
10.
10
Sign-Magnitude Representation
One schemeis sign-magnitude. It uses one bit
(usually the leftmost) to indicate the sign.
"0“ - indicates a positive integer
"1“ - indicates a negative integer
The rest of the bits are used for the magnitude of
the number.
Eg. -2410
is represented as: 1001 1000
+2410
is represented as: 0001 1000
8-bit number can represent from -127 to +127.
-127 (1111 1111) to +127 (0111 1111)
11.
11
Complimentary Arithmetic
Complements usedin digital computers for
simplifying;
The subtraction operation.
The logical manipulation.
There are two types of compliments system
One’s compliments
Two’s compliments
12.
12
One’s Compliment
Thereforethe 1’s compliment of a binary number
is formed by changing 1’s into 0’s and 0’s into
1’s.
Example: 1’s compliment of 1011001 is
0100110.
Exercise: get the 1’s compliments of the following
binary numbers.
1. 1100011 = 0011100
2. 0001111 = 1110000
3. 1010100 = 0101011
4. 1111011 = 0000100
13.
Example 1 :Store -27 in a byte using 2's complement notation.
Step 0: +27 in binary is 0 0 0 1 1 0 1 1
Step 1: Invert bits 1 1 1 0 0 1 0 0
Then the 1's complement of -27 is 1110 0100.
Step 2: Add 1 to the 1's complement:
1 1 1 0 0 1 0 0
+ 1
1 1 1 0 0 1 0 1
The 2's complement of -27 is 1110 0101. 13
Two’s Compliment
Step 1: Get the 1’s compliment of the given
number.
Step 2: Add ‘1’ to the 1’s compliment.
14.
Example 1: Store the integer -70 in a byte using the two's
complement notation.
Step 0: Write the +70 in binary 0 1 0 0 0 1 1 0
Step 1: Take the 1’s compliment (Invert the contents
of the byte.) 1 0 1 1 1 0 0 1
Then the 1's complement of -70 is 1011 1001.
Step 2: Add ‘1’ to the LSB of 1's complement value:
1 0 1 1 1 0 0 1
+ 1
1 0 1 1 1 0 1 0
The 2's complement of -70 is 1011 1010.
Therefor we store the integer -70 in a byte in 2’s
complement from as 1011 1010.
14
15.
15
Binary Multiplication
Rules ofBinary Multiplication
0 x 0 = 0
0 x 1 = 0
1 x 0 = 0
1 x 1 = 1, and no carry or borrow bits
Examples 1: 3 X 3 = 9
0011 X 0011 = 1001
0011
0011 x
0011
00110 the ‘0’ here is the placeholder
1001 Answer is 9
16.
16
Binary Multiplication
Examples 2:1001 x 0111 =?
1001 x 0111 = 1001 x 111 = 9 x 7 =63
1001
111
1001
10010
100100
111111 63
Binary multiplication achieved by Shifting & Adding.
The two numbers are called Multiplicand & Multiplier.
17.
17
Binary Division
Toperform the binary division follow these steps.
1. Align the divisor (Y) with the most significant end of the
dividend. Let the portion of the dividend from its MSB to
its bit aligned with the LSB of the divisor be denoted X.
2. Compare X and Y.
If X >= Y, the quotient bit is 1 an perform the subtraction
X-Y.
If X < Y, the quotient bit is 0 and do not perform any
subtractions.
3. Shift Y one bit to the right and go to step 2.
Question: By usingComplimentary Arithmetic
method, do this digital Binary subtraction.
(Hint: Use 2’s compliment & 8 bit representation of the numbers)
20
Exercise:
1. 1011011 − 10010 = ?
=01001001
2. 100010110 − 1111010 = ?
=10011100
3. 1010110 − 101010 = ?
=00101100
4. 101101 − 100111 = ?
=00000 110
5. 1000101 − 101100 = ?
=00011001
6. 1110110 − 1010111 = ?
=00011111
16
- 3
13
0001 0000
1111 1101
1 0000 1101
21.
21
A variety oflogic gates are commonly used in
computers.
What are the basic type of gates?
(Hint: There are three type)
What are the main derive type of gates?
(Hint: There are four type)
Home Work Question: