IN 1300
Digital Fundamental and
Computer System
FACULTY of INFORMATION
TECHNOLOGY
UNIVERSITY of MORATUWA
1
Important Notice
Please
Switch
Off
Mobile
Phones
2
Lesson 02
Digital Fundamental
by
Eng. H. D. A. Gunasekara
Lecturer
Department of Information Technology
University of Moratuwa
3
4
Binary Addition
Rules of Binary Addition
 0 + 0 = 0
 0 + 1 = 1
 1 + 0 = 1
 1 + 1 = 0, and carry 1 to the next more significant bit.
 1 + 1 + 1 = 1, and carry 1 to the next more significant bit.
5
Binary Addition – Examples
Exercise :
1. 10001 + 11101 = ?
2. 1110 + 1111 = ?
3. 101101 + 11001 = ?
4. 10111 + 110101 = ?
5. 1011001 + 111010 = ?
6. 11011 + 1001010 = ?
= 101110
= 11101
= 1000110
= 1001100
= 10010011
= 1100101
Rules of Binary Subtraction
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
.00110011 51
- 00010110 22
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
8
Binary Subtraction – Examples
16
- 3
13
Exercise:
1. 1011011 − 10010 = ?
=1001001
2. 100010110 − 1111010 = ?
=10011100
3. 1010110 − 101010 = ?
=101100
4. 101101 − 100111 = ?
=110
5. 1000101 − 101100 = ?
=11001
6. 1110110 − 1010111 = ?
=11111
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
Sign-Magnitude Representation
One scheme is 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
Complimentary Arithmetic
Complements used in digital computers for
simplifying;
 The subtraction operation.
 The logical manipulation.
There are two types of compliments system
 One’s compliments
 Two’s compliments
12
One’s Compliment
 Therefore the 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
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.
 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
Binary Multiplication
Rules of Binary 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
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
Binary Division
 To perform 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.
18
Binary Division
Examples 1: 110101/ 111
19
Binary Division
Examples 2: 11100110/110
Exercise :
1. 1000 /10
= 100
2. 1010 / 11
= 11
3. 1111/ 111
= 10
Question: By using Complimentary 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
A variety of logic 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:
22
End of Lecture 02

IN 1300 LEC_D02(B15) Basic electronic 2.pdf

  • 1.
    IN 1300 Digital Fundamentaland Computer System FACULTY of INFORMATION TECHNOLOGY UNIVERSITY of MORATUWA 1
  • 2.
  • 3.
    Lesson 02 Digital Fundamental by Eng.H. D. A. Gunasekara Lecturer Department of Information Technology University of Moratuwa 3
  • 4.
    4 Binary Addition Rules ofBinary Addition  0 + 0 = 0  0 + 1 = 1  1 + 0 = 1  1 + 1 = 0, and carry 1 to the next more significant bit.  1 + 1 + 1 = 1, and carry 1 to the next more significant bit.
  • 5.
    5 Binary Addition –Examples Exercise : 1. 10001 + 11101 = ? 2. 1110 + 1111 = ? 3. 101101 + 11001 = ? 4. 10111 + 110101 = ? 5. 1011001 + 111010 = ? 6. 11011 + 1001010 = ? = 101110 = 11101 = 1000110 = 1001100 = 10010011 = 1100101
  • 6.
    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
  • 8.
    8 Binary Subtraction –Examples 16 - 3 13 Exercise: 1. 1011011 − 10010 = ? =1001001 2. 100010110 − 1111010 = ? =10011100 3. 1010110 − 101010 = ? =101100 4. 101101 − 100111 = ? =110 5. 1000101 − 101100 = ? =11001 6. 1110110 − 1010111 = ? =11111
  • 9.
    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.
  • 18.
  • 19.
    19 Binary Division Examples 2:11100110/110 Exercise : 1. 1000 /10 = 100 2. 1010 / 11 = 11 3. 1111/ 111 = 10
  • 20.
    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:
  • 22.