0% found this document useful (0 votes)
60 views36 pages

Chapter 9 The Building Blocks Binary Numbers, Boolean Logic, and Gates

The document discusses data representation in computers including binary numbers, Boolean logic, and logic gates. It defines basic units of data storage like bits and bytes. It describes different data types like text, numbers, images, audio and video and how they are represented using bits. It also discusses number systems like binary, decimal, octal and hexadecimal. It explains conversions between these number systems. Finally, it introduces Boolean logic and logic gates, defining operations like AND, OR and NOT and how they are used to represent true and false values in digital circuits.

Uploaded by

qgx8pbrqbp
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)
60 views36 pages

Chapter 9 The Building Blocks Binary Numbers, Boolean Logic, and Gates

The document discusses data representation in computers including binary numbers, Boolean logic, and logic gates. It defines basic units of data storage like bits and bytes. It describes different data types like text, numbers, images, audio and video and how they are represented using bits. It also discusses number systems like binary, decimal, octal and hexadecimal. It explains conversions between these number systems. Finally, it introduces Boolean logic and logic gates, defining operations like AND, OR and NOT and how they are used to represent true and false values in digital circuits.

Uploaded by

qgx8pbrqbp
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/ 36

Chapter 3

The Building Blocks: Binary Numbers, Boolean


Logic, and Gates
Chapter 9
The Building Blocks: Binary Numbers, Boolean
Logic, and Gates
Objectives
• After studying this chapter, students will be able to :
– Distinguish various types of Data
– Get familiar with the types of data representation in
computer
– Do conversions from:
• Any Base(Binary, Octal or Hexadecimal) to Decimal number
• Decimal to Binary or Octal or Hexadecimal
• Binary to Octal
• Binary to Hexadecimal
– Do bit operations - adding binary numbers
– Build truth tables for Boolean expressions and determine
when they are true or false
– Familiar with logical gates and circuits using these gates
3
Data Representation

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).

3) Byte:– A bit pattern of length 8 is called a byte.


8 bits = 1 Byte
This term(byte) is used to measure the size of the memory

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.

2. Numbers: A sequence of 0’s and 1’s represents a number.

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.

Pixel(picture element): is a smallest display unit (dot)


of digital image or graphic.

b. Vector Graphic: image contains curves and lines.

8
Data Representation (continued)
4. Audio: uses bit patterns to store audio.

5. Video: is a representation of images (called frames)
in time.

• Each image or frame is changed to a set of bit


patterns and stored.

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

1. External representation is human-oriented


– base-10 numbers
– keyboard characters
2. Internal representation is computer-oriented
– base-2 for numbers ( in binary 0’s and 1’s)
– base-2 codes for characters

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

4. Hexadecimal Number System (Base 16)


Uses: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
where
A=10, B=11, C=12, D=13, E=14 and F=15

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

Example1 : (110)2 = 1x 2 3−1 + 1x 2 3− 2 + 0 x 2 3−3


= 1x 2 2 + 1x 21 + 0 x 2 0 = 4 + 2 + 0 = 6
Example2 : (00101) 2 = 0 x 2 4 + 0 x 2 3 + 1x 2 2 + 0 x 21 + 1x 2 0
= 0 + 0 + 4 + 0 +1 = 5 18
Any base to Decimal Conversion
Example − 3 : (10101.11) 2 = 1x 2 5−1 + 0 x 2 5−2 + 1x 2 5−3 + 0 x 2 5−4 + 1x 2 5−5 + 1x 2 −1 + 1x 2 −2
= 1x 2 4 + 0 x 2 3 + 1x 2 2 + 0 x 21 + 1x 2 0 + 1x 2 −1 + 1x 2 −2
1 1
= 1x16 + 0 x8 + 1x 4 + 0 x 2 + 1x1 + + = 16 + 4 + 1 + 0.5 + 0.25 = 21.75
2 4
Example − 4 : (127) 8 = 1x83−1 + 2 x83−2 + 7 x83−3
= 8 2 + 2 x8 + 7 x1
= 64 + 16 + 7 = (87)10
Example − 5 : (5 AB )16 = 5 x16 3−1 + Ax16 3−2 + Bx16 3−3
= 5 x16 2 + 10 x16 + 11x1
= 5 x 256 + 160 + 11 = 1280 + 160 + 11 = (1451)10
19
Decimal to Binary Conversion
• Converting from decimal to binary
– Repeatedly divide by two(2) and record the
remainder
– Example, convert (13)10= ( ? )2:

• 2 13 – 12 = 1
• 2 6–6 =0
• 2 3–2 =1
• 2 1–0 =1
• 0

• Result of (13)10= (1101)2


20
Decimal to Octal Conversion

• Converting from Decimal to Octal


– Repeatedly divide by eight(8) and record the
remainder
– Example, convert (79)10= ( ? )8:
• 8 79 – 72 = 7
• 8 9–8 =1
• 8 1–0 =1
• 0

• Result of (79)10= (117)8

21
Decimal to Hexadecimal Conversion

• Converting from Hexadecimal to Decimal


– Repeatedly divide by sixteen(16) and record the
remainder
– Example, convert (79)10= ( ? )16:
• 16 79 – 64 = 15 = F
• 16 4 – 0 = 4
• 0

• Result of (79)10= (4F)16

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

001 010 111 101 = 1275

23
Binary to Hexadecimal Conversion

• Converting from binary to Hexadecimal


• Example : Convert the binary number
1010111101 to Hexadecimal.
• We divide the number into groups of 4 bits
starting from the rightmost side. So,
10 1011 1101

0010 1011 1101 = 2BD

24
Operations on Bits

• Question: What are the arithmetic operations?


• Answer: Arithmetic Operation are:
1. Addition (+)
2. Subtraction (-)
3. Multiplication (*)
4. and Division (/)
25
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.

Construction of computer circuits is based on Boolean


logic.

Question: What is a Boolean expression?


Boolean expression: Any expression that evaluates to
either true or false.

Truth table: captures the output/value of a Boolean


expression. 28
Boolean Logic (continued)
• Boolean logic operations are: AND, OR, NOT

• Question: Give the example of binary operator.


How many operands binary operator requires?
• Answer: Binary operators requires two operands.

• Example: In a+b , + is a binary operator because it


requires two operands a and b.

29
Boolean Logic (continued)

• Question: Give the example of unary operator.


How many operands unary operator requires?
• Answer:Unary operator: requires only one operand.

• Example: In –a+b , – is a uniary operator since it


requires only one operator i.e., a.

• NOT operation: reverses or complements the value of


a boolean expression.

30
Gates
• Definition of Gate:
• Gate: is an electronic device that operates on a
collection of binary inputs to produce a binary output.

A gate transforms a set of (0 or 1) input values into a


single output value ( 0 or 1).

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

You might also like