Chapter 9 The Building Blocks Binary Numbers, Boolean Logic, and Gates
Chapter 9 The Building Blocks Binary Numbers, Boolean Logic, and Gates
Basic Definitions:
1) Bit (Binary digit): is the smallest unit of data that can be
stored in a computer.
- It is either 0 or 1.
2) Bit Pattern: is a sequence of bits (or a string of bits).
4
Data Representation (continued)
Question: Write about the various types of data which we
can represent in the computer with a diagram.
Answer: Data Types: Data come in different forms such as
1. Text
2. Numbers
3. Images
4. Audio
5. Video.
5
Data Representation (continued)
Definitions:
1. Text: is a sequence of symbols used to represent an idea.
6
Data Representation (continued)
3. Images: are represented in a computer by one of two
methods:
a) Bitmap graphic or
b) Vector graphic
7
Data Representation (continued)
a. Bitmap Graphic: image is divided into a matrix of
pixels.
8
Data Representation (continued)
4. Audio: uses bit patterns to store audio.
•
5. Video: is a representation of images (called frames)
in time.
9
Data Representation (continued)
• Different sets of bit patterns have been designed to
represent text symbols.
1) American Standard Code for Information Interchange
(ASCII):
- Uses a 7 bit pattern ranging from 0000000 to 1111111
2) Extended ASCII
- To make the size of each pattern 1 byte (8 bits)
• 3) Extended Binary Coded Decimal Interchange Code
(EBCDIC)
– This code uses 8 bits patterns, so it can represent up to 256 symbols.
• 4) Unicode
– Uses 16 bits and can represent up to 65,536 symbols.
• 5) International Organization for Standardization (ISO)
• – Uses 32 bits patterns and can represent up to 4,294,967,296 10
The Number Systems
11
12
The Number Systems
Question: How many types of number systems are there?
What are they?
Answer: There are four types of number systems. They are:
1. Decimal Number System ( Decimal means 10 )
2. Binary Number System( Bi or binary means 2 )
3. Octal Number System ( Octal means 8)
4. Hexadecimal Number System ( Hexadecimal means 16)
13
The Number Systems
Questions: Write about the four number systems with
examples:
Answer:
1. Decimal Number System ( Base 10)
Uses :10 digits i.e., 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Each place corresponds to a power of 10
Example:
1943=1000+900+40+3
=1x1000+9x100+4x10+3
= 1 * 103 + 9 * 102 + 4 * 101 + 3 * 100
2. Binary Number System(Base 2)
Uses: 2 digits: 0 and 1
Each place corresponds to a power of 2
14
1101 = 1 * 23 + 1 * 22 + 0 * 21 + 1 * 20 = 13
The Number Systems(continued)
3. Octal Number System (Base 8)
Uses : 0,1,2,3,4,5,6,7 numbers
15
Examples of Number Systems
16
17
Conversion from any base(Binary,Octal ,Hexa) to
Decimal number
Any base (Binary, Octal ,Hexadecimal) to Decimal
General Formula is:
• an-1rn-1 + an-2rn-2 + an-3rn-3 + an-4rn-4+… + a0r0
+ a-1r -1 + a-2r -2 + a-3r -3+ …..
n=no. of digits
r = base
an-1, an-2, an-3… are the digits
21
Decimal to Hexadecimal Conversion
22
Binary to Octal Conversion
• Converting from binary to octal
• Example : Convert the binary number
1010111101 to Octal.
• We divide the number into groups of 3 bits
starting from the rightmost side. So,
•
• 1 010 111 101
23
Binary to Hexadecimal Conversion
24
Operations on Bits
26
Operations on Bits(continued)
Example 2:
101101 2 + 000111 2 = (??? ) 2 using Operation on bits
Solution :
Carry 1 1 1 1
000111
+ 101101
110100
27
Boolean Logic
• Question: What is Boolean logic?
• Boolean logic: (in mathematics) uses values true and
false.
29
Boolean Logic (continued)
30
Gates
• Definition of Gate:
• Gate: is an electronic device that operates on a
collection of binary inputs to produce a binary output.
31
Gates
• Truth table for AND,OR and NOT gates
32
Gates
Question: What are the three basic types if gates?
Explain with the help of their diagrams and truth tables?
Answer: The three types of gates are:
1. AND gate
2. OR gate
3. NOT gate
33
Figure 4.15 The Three Basic Gates and Their Symbols
Figure 4.22 One-Bit Compare for Equality Circuit
34
a b a AND b C1 OR C2
(C1)
0 0 0 1 1 1 1
0 1 0 1 0 0 0
1 0 0 0 1 0 0
1 1 1 0 0 0 1
35
Figure 4.22 One-Bit Compare for Equality Circuit
35