ICT Lecture 04

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 59

Introduction to Information and

Communication Technology (ICT)(CS-301)

Instructor : Dr. Abdul Razzaq


Email: abdul.razzaq@mnsuam.edu.pk

ICT(CS-301)
Lecture 04
Binary Numbers(Data
Representation)
& Logic Operations

Please be on time
(better: before time)
The focus of the last lecture was on the
Essential Components of the computer
• During that lecture we also learnt about the function
of the central component of a computer, the
microprocessor
• And its various sub-systems
– Bus interface unit
– Data & instruction cache memory
– Instruction decoder
– ALU
– Floating-point unit
– Control unit
Learning Goals for Today
1. To become familiar with number system used by
the microprocessors - binary numbers

2. To become able to perform decimal-to-binary


conversions

3. To understand the NOT, AND, OR and XOR logic


operations – the fundamental operations that are
available in all microprocessors
Number Systems
• Two types of number systems are:

 Non-positional number systems


 Positional number systems
Non-positional Number Systems

• Characteristics
• Use symbols such as I for 1, II for 2, III for 3, IIII
for 4, IIIII for 5, etc
• Each symbol represents the same value
regardless of its position in the number
• The symbols are simply added to find out the
value of a particular number
• Difficulty
• It is difficult to perform arithmetic with such a
number system
Positional Number Systems
• Characteristics
• Use only a few symbols called digits
• These symbols represent different values
depending on the position they occupy in the number
• The value of each digit is determined by:
• The digit itself
• The position of the digit in the number
• The base of the number system
• (base = total number of digits in the number
system)
– The maximum value of a single digit is always
equal to one less than the value of the base
DECIMAL
(BASE 10)
numbers
Decimal Number System
• Characteristics
• A positional number system
• Has 10 symbols or digits (0, 1, 2, 3, 4, 5, 6,

7,8,9). Hence, its base = 10


The maximum value of a single digit is 9 (one less
than the value of the base)
• We use this number system in our day-
to-day life
Decimal (base 10) number system
consists of 10 symbols or digits

0 1 2 3 4
5 6 7 8 9
BINARY
(BASE 2)
numbers
Binary Number System
• Characteristics
– A positional number system
– Has only 2 symbols or digits (0 and 1). Hence its
base = 2
– The maximum value of a single digit is 1 (one less
than the value of the base)
– Each position of a digit represents a specific
power of the base (2)
– This number system is used in computers
Binary (base 2) number system
consists of just two

01
Other popular number systems
• Octal
– base = 8
– 8 symbols (0,1,2,3,4,5,6,7)

• Hexadecimal
– base = 16
– 16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
Decimal (base 10) numbers are
expressed in the positional notation

The right-most is the least significant digit

4202 = 2x100 + 0x101 + 2x102 + 4x103

The left-most is the most significant digit


Decimal (base 10) numbers are
expressed in the positional notation

4202 = 2x100 + 0x101 + 2x102 + 4x103

1’s multiplier
Decimal (base 10) numbers are
expressed in the positional notation

10

4202 = 2x100 + 0x101 + 2x102 + 4x103

10’s multiplier
Decimal (base 10) numbers are
expressed in the positional notation

100

4202 = 2x100 + 0x101 + 2x102 + 4x103

100’s multiplier
Decimal (base 10) numbers are
expressed in the positional notation

1000

4202 = 2x100 + 0x101 + 2x102 + 4x103

1000’s multiplier
Binary (base 2) numbers are also
expressed in the positional notation

The right-most is the least significant digit

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

The left-most is the most significant digit


Binary (base 2) numbers are also
expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

1’s multiplier
Binary (base 2) numbers are also
expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

2’s multiplier
Binary (base 2) numbers are also
expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

4’s multiplier
Binary (base 2) numbers are also
expressed in the positional notation

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

8’s multiplier
Binary (base 2) numbers are also
expressed in the positional notation

16

10011 = 1x20 + 1x21 + 0x22 + 0x23 + 1x24

16’s multiplier
Counting Counting
in Decimal in Binary
0 10 20 30 0 1010 10100 11110
1 11 21 31 1 1011 10101 11111
2 12 22 32 10 1100 10110 100000
3 13 23 33 11 1101 10111 100001
4 14 24 34 100 1110 11000 100010
5 15 25 35 101 1111 11001 100011
6 16 26 36 110 10000 11010 100100
7 17 27 . 111 10001 11011 .
8 18 28 . 1000 10010 11100 .
9 19 29 . 1001 10011 11101 .
Why binary ?
Because this system is natural for digital computers

The fundamental building block of a digital computer –


the switch – possesses two natural states, ON & OFF.

It is natural to represent those states in a number


system that has only two symbols, 1 and 0, i.e. the
binary number system

In some ways, the decimal number system is natural


to us humans. Why?
bit
binary digit
Byte = 8 bits
Number
conversion
There are many methods or techniques which can be used to convert
numbers from one base to another.
We'll demonstrate here the following

• Decimal to Other Base System


• Other Base System to Decimal
• Other Base System to Non-Decimal
• Binary to Octal
• Octal to Binary
• Binary to Hexadecimal
• Hexadecimal to Binary Why?
Decimal Binary
conversion
Steps:
Step 1 - Divide the decimal number to be converted
by the value of the new base.

Step 2 - Get the remainder from Step 1 as the


rightmost digit (least significant digit) of new base
number.
Step 3 - Divide the quotient of the previous divide by
the new base.
Step 4 - Record the remainder from Step 3 as the
next digit (to the left) of the new base number.

Repeat Steps 3 and 4, getting remainders from right to left, until


Convert 75 to Binary
2 75 remainder
2 37 1
2 18 1
2 9 0
2 4 1
2 2 0
2 1 0
0 1

1001011
Check

1001011 = 1x20 + 1x21 + 0x22 + 1x23


+ 0x24 + 0x25 + 1x26
= 1 + 2 + 0 + 8 + 0 + 0 + 64
= 75
Convert 100 to Binary
2 100 remainder
2 50 0
2 25 0
2 12 1
2 6 0
2 3 0
2 1 1
0 1

1100100
Converting a Number of Another Base to a
Decimal Number
• Step 1: Determine the column (positional) value
of each digit
• Step 2: Multiply the obtained column values by
the digits in the corresponding columns
• Step 3: Calculate the sum of these products

Converting a Number of Another Base to a
Decimal Number
• Step 1: Determine the column (positional) value
of each digit
• Step 2: Multiply the obtained column values by
the digits in the corresponding columns
• Step 3: Calculate the sum of these products
That finishes our first topic - introduction
to binary numbers and their conversion
to and from decimal numbers

Our next topic is …


Boolean
Logic
Operations
Let x, y, z be Boolean
variables. Boolean variables can
only have binary values i.e., they can
have values which are either 0 or 1

For example, if we represent the state of


a light switch with a Boolean variable x,
we will assign a value of 0 to x when the
switch is OFF, and 1 when it is ON
A few other names for the states
of these Boolean variables
0 1

Off On

Low High

False True
We define the following logic operations
or functions among the Boolean variables

Name Example Symbolically


NOT y = NOT(x) x´
AND z = x AND y x·y
OR z = x OR y x+y
z = x XOR
xy
XOR y
We’ll define these operations with the help of
truth tables

what is the truth table


of a logic function
?
A truth table defines the output of a
logic function for all possible inputs
Truth Table for the NOT Operation
(y true whenever x is false)
x y = x´
0
1
Truth Table for the NOT Operation

x y = x´
0 1
1 0
Truth Table for the AND Operation
(z true when both x & y true)
x y z=x·y
0 0
0 1
1 0
1 1
Truth Table for the AND Operation

x y z=x·y
0 0 0
0 1 0
1 0 0
1 1 1
Truth Table for the OR Operation
(z true when x or y or both true)
x y z=x+y
0 0
0 1
1 0
1 1
Truth Table for the OR Operation

x y z=x+y
0 0 0
0 1 1
1 0 1
1 1 1
Truth Table for the XOR Operation
(z true when x or y true, but not both)

x y z=xy
0 0
0 1
1 0
1 1
Truth Table for the XOR Operation

x y z=xy
0 0 0
0 1 1
1 0 1
1 1 0
Those 4 were the fundamental logic operations.
Here are examples of a few more complex situations

z = (x + y)´

z = y · (x + y)

z = (y · x)  w

STRATEGY: Divide & Conquer


z = (x + y)´
x y x + y z = (x + y)´
0 0 0 1
0 1 1 0
1 0 1 0
1 1 1 0
z = y · (x + y)
x y x + y z = y · (x + y)
0 0 0 0
0 1 1 1
1 0 1 0
1 1 1 1
z = (y · x)  w
x y w y · x z = (y · x)  w
0 0 0 0 0
0 0 1 0 1
0 1 0 0 0
0 1 1 0 1
1 0 0 0 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 0
Number of rows in a truth table?

n
2
n = number of input variables
Assignment # 1
Rules for Marking
It should be clear that your assignment will not get any
credit(Zero Marks) if:
• The assignment is submitted after due date.
• No assignment will be accepted via E-mail.( Submitted in Paper format)
• The assignment is copied.
• …………………………………………………………………………………
A. Convert the following into binary numbers:
i. The last three digits of your roll number
ii. 256
B. x, y & z are Boolean variables. Determine the truth tables for the
following combinations:
i. (x · y) + y
ii. (x  y)´ + w
C. What is difference between an Embedded System & General Purpose
Computer?
What have we learnt today?
1. About the binary number system, and how it differs
from the decimal system

2. Positional notation for representing binary and


decimal numbers

3. A process (or algorithm) which can be used to


convert decimal numbers to binary numbers

4. Basic logic operations for Boolean variables, i.e.


NOT, OR, AND, XOR, NOR, NAND, XNOR

5. Construction of truth tables (How many rows?)

You might also like