0% found this document useful (0 votes)
13 views29 pages

Module 5_Digital Logic and Number Systems-P1

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, along with their interconversions. It covers binary-coded decimal (BCD), Excess-3 code, Gray code, and the concepts of one's and two's complements, as well as basic binary arithmetic operations. Additionally, it includes problem-solving exercises related to these topics.

Uploaded by

dueltmpotc8w
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views29 pages

Module 5_Digital Logic and Number Systems-P1

The document provides an overview of various number systems including decimal, binary, octal, and hexadecimal, along with their interconversions. It covers binary-coded decimal (BCD), Excess-3 code, Gray code, and the concepts of one's and two's complements, as well as basic binary arithmetic operations. Additionally, it includes problem-solving exercises related to these topics.

Uploaded by

dueltmpotc8w
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

I.

Introduction to decimal, binary, octal, hexadecimal


number systems
II. Interconversions
III. BCD code, Excess - 3 code, Gray code
IV. One’s and two’s complements
V. Simple binary arithmetic operations
Addition, subtraction, multiplication and division

2
I. Positive and negative logic
II. Basic and derived logic gates, symbols and their
truth tables
AND, OR, NOT, NAND, NOR, XOR, and XNOR
III. Boolean algebra
IV. Basic laws of Boolean algebra
V. De-Morgan’s theorems
VI. Reducing Boolean expressions using Boolean laws

3
Day 1:
I. Introduction to decimal, binary, octal, hexadecimal
number systems
II. Interconversions
Day 2:
III. BCD code, Excess - 3 code, Gray code
Day 3:
IV. One’s and two’s complements
V. Simple binary arithmetic operations
Addition, subtraction, multiplication and division
Day 4: Review and Problem solving
4
5
P1 - I. Introduction to number systems

How about quaternary numeral system (base 4)?

6
P1 - I. Introduction to number systems
The Decimal System

• Most significant digit • Least significant digit


• The leftmost digit (carries the • The rightmost digit
highest value)
7
P1 - I. Introduction to number systems
The Decimal System

To convert a number from any base (let's call it base (b)) to a decimal
number (base-10), you can use the following general formula:

• Why Decimal common and important?


• How about ZERO number?

8
P1 - I. Introduction to number systems
The Binary System
• Only two digits, 1 and 0
• Represented to the base 2
• The digits 1 and 0 in binary notation have the same meaning as in decimal notation:
02 = 010
12 = 110
• To represent larger numbers each digit in a binary number has a value depending on its
position:
102 = (1 * 21) + (0 * 20) = 210
112 = (1 * 21) + (1 * 20) = 310
1002 = (1 * 22) + (0 * 21) + (0 * 20) = 410
and so on. Again, fractional values are represented with negative powers of the radix:
1001.101 = 23 + 20 + 2-1 + 2-3 = 9.62510

9
P1 - I. Introduction to number systems
The Octal System

The Hexadecimal System

10
= 0 1
2

P1 - II. Interconversion
1011 = 11 2 10

(a) 1110
Converting Decimal to Binary (Integers)
Quotient Remainder
21 = 10 1
2

10 = 5 0
2

5 = 2 1
2

2 = 1 0
2

1 = 0 1
2
101012 = 2110

(b) 2110

Figure 9.1 Examples of Converting from Decimal 11


Notation to Binary Notation for Integers
0.48 2 = 0.96 0

P1 - II. Interconversion
0.96 2 = 1.92 1

Converting Decimal to Binary (Fractions)


0.92 2 = 1.84 1

(a) 0.81 10 = 0.110011 2 (approximately)


Product Integer Part 0.110011 2
0.81 2 = 1.62 1

0.62 2 = 1.24 1 Product Integer Part 0.012


0.25 2 = 0.5 0
0.24 2 = 0.48 0

0.5 2 = 1.0 1
0.48 2 = 0.96 0

(b) 0.25 10 = 0.012 (exactly)


0.96 2 = 1.92 1

0.92 2 = 1.84 1

Figure 9.2 Examples of Converting from Decimal


(a) 0.81 10 = 0.110011 2 (approximately)
Notation to Binary Notation for Fractions
12
P1 - II. Interconversion
Converting Binary to Decimal

13
P1 - II. Interconversion
Converting Binary to Hexadecimal
• Binary digits are grouped into sets of four bits, called a nibble
• Each possible combination of four binary digits is given a symbol, as follows:
0000 = 0 0100 = 4 1000 = 8 1100 = C
0001 = 1 0101 = 5 1001 = 9 1101 = D
0010 = 2 0110 = 6 1010 = A 1110 = E
0011 = 3 0111 = 7 1011 = B 1111 = F
• Because 16 symbols are used, the notation is called hexadecimal and the 16 symbols
are the hexadecimal digits
• Thus
2C16 = (216 * 161) + (C16 * 160)
= (210 * 161) + (1210 * 160) = 44

→ So how about Octal (base 8)?


14
P1 - II. Interconversion
Converting Octal → Hexadecimal
• Hexadecimal → Octal
• STEP 1: Hexadecimal → Binary (nibble: 4 bits)
• STEP 2: Binary → Octal (nibble: 3 bits)
• Example: 9F1216 = 1174228

• Octal → Hexadecimal
• STEP 1: Octal → Binary (nibble: 3 bits)
• STEP 2: Binary → Hexadecimal (nibble: 4 bits)
• Example: 52.448 = 2A.9116

15
P1 - III. BCD code, Excess – 3 code, Gray code
BCD Code (Binary-Coded Decimal)
• BCD is a binary encoding of decimal numbers where each
digit is represented by its own binary sequence.

• Commonly used in digital systems like calculators and


digital clocks.

• Example: The decimal number 59 in BCD is:


5 in decimal = 0101 in binary
9 in decimal = 1001 in binary
→ 59 in BCD = 0101 1001
16
P1 - III. BCD code, Excess – 3 code, Gray code
Excess – 3 code
• Excess-3 is a binary-coded decimal code derived by adding 3
to each decimal digit and then converting the result to
binary.

• Used in some digital systems for error detection.

• Example: The decimal number 59 in Excess-3 is:


5 in decimal + 3 = 8, which is 1000 in binary
9 in decimal + 3 = 12, which is 1100 in binary
→ 59 in Excess-3 = 1000 1100
17
P1 - III. BCD code, Excess – 3 code, Gray code
Gray code (Reflected Binary Code - RBC)
• Gray code is a binary numeral system where two successive
values differ in only one bit.
• “Unit distance code” or “Minimum error code”

• Used in error correction in digital communications and to


prevent errors in digital systems.

• Example: The decimal number 5 in Gray code is:


Binary of 5 = 101
Gray code of 5 = 111 (since 101 -> 111)
18
P1 - III. BCD code, Excess – 3 code, Gray code
Binary to Gray conversion:
• The Most Significant Bit (MSB) of the gray code is always
equal to the MSB of the given binary code.
• Other bits of the output gray code can be obtained by
XORing binary code bit at that index and previous index.
Quiz:
What is Gray code of Binary 101001?
a) 110101
b) 111101
c) 101101
d) 111001
19
P1 - III. BCD code, Excess – 3 code, Gray code
Gray to binary conversion:
• The Most Significant Bit (MSB) of the binary code is always equal to
the MSB of the given gray code.
• Other bits of the output binary code can be obtained by checking the
gray code bit at that index. If the current gray code bit is 0, then copy
the previous binary code bit, else copy the invert of the previous
binary code bit. Quiz:
What is Binary code of Gray 110110?
a) 111010
b) 100110
c) 100100
d) 101001
20
P1 - IV. One’s and two’s complements
One’s and two’s complements
• One's complement of a binary number is obtained by inverting all the bits
(changing 0s to 1s and 1s to 0s).

• Two's complement of a binary number is obtained by taking the one's


complement of the number and then adding 1 to the least significant bit (LSB).

• Widely used in modern computer systems for representing negative numbers

• Example:
• Binary number: 1010
• One's complement: 0101
• Add 1: 0101 + 1 = 0110
• Two's complement: 0110

21
P1 - V. Simple binary arithmetic operations
Addition, Subtraction, Multiplication, Division

0-1

22
P1 - V. Simple binary arithmetic operations
Addition (Unsigned binary number)

10001 + 11101 = ?
10111 + 110001 = ?
23
P1 - V. Simple binary arithmetic operations
Subtraction (unsigned binary numbers)

1010 - 101 = ?
0011010 – 001100 = ?
24
P1 - V. Simple binary arithmetic operations
Multiplication (unsigned binary numbers)

1010 × 101 = ?
1011.01 × 110.1 = ?
25
P1 - V. Simple binary arithmetic operations
Division (unsigned binary number)

➢ Example: (do by yourself)


▪ Divide ( 1010 ) by ( 10 ) (10 by 2
in decimal))
▪ Divide ( 101101 ) by ( 101 ) (45 by
5 in decimal)
▪ Divide ( 1101 ) by ( 11 ) (13 by 3 in
decimal)

26
P1 - V. Simple binary arithmetic operations
Thumb rules for performing arithmetic operations
on signed binary numbers:
➢ Convert the negative number using two’s complements
➢ Perform the operation (as they were unsigned)
➢ Adjust the sign of the resultant (if negative, convert to its two's
complement form)
* For fractional numbers:
✓ Align the Binary Points, perform integer and fraction part separately
* For multiplication:
✓ Consider sign-bit extension [1 for negative numbers]
✓ Consider number of bit required
27
P1 – Review and Problem Solving

Interconversion:
1- Convert 13.25 to binary, octal and hexadecimal (direct and indirect)
2- Convert 2FA.516 to octal

Coding:
1- Find BCD of 123 and -45 using 4-bit system
2- Convert 375 to Excess-3 Code
3- Find gray code of binary 110.01 and find binary code of the gray 101.10

Arithmetic operation:
1- Perform 4 binary arithmetic operations for the unsigned numbers 5 and 3
2- Perform 4 binary arithmetic operations for the signed numbers -5 and +3

28
29

You might also like