intro to comp lec 3 final 1
TRANSCRIPT
-
8/2/2019 Intro to Comp Lec 3 Final 1
1/50
Introduction To ComputingIntroduction To Computing
Chapter 3Chapter 3
Number SystemNumber System
Marium Jalal ChaudhryMarium Jalal Chaudhry
-
8/2/2019 Intro to Comp Lec 3 Final 1
2/50
Learning Goals for TodayLearning Goals for Today
1.1. To become familiar with number system used byTo become familiar with number system used bythe microprocessors -the microprocessors - binary numbersbinary numbers
2.2. To become able to performTo become able to perform decimal-to-binarydecimal-to-binaryconversionsconversions
3.3. To understand the NOT, AND, OR and XORTo understand the NOT, AND, OR and XOR logiclogic
operationsoperations the fundamental operations that arethe fundamental operations that are
available in all microprocessorsavailable in all microprocessors
-
8/2/2019 Intro to Comp Lec 3 Final 1
3/50
BINARYBINARY(BASE(BASE 22))
numbersnumbers
-
8/2/2019 Intro to Comp Lec 3 Final 1
4/50
DECIMALDECIMAL(BASE(BASE 1010))
numbersnumbers
-
8/2/2019 Intro to Comp Lec 3 Final 1
5/50
Decimal (base 10) number systemDecimal (base 10) number system
consists of 10 symbols or digitsconsists of 10 symbols or digits
0 1 2 3 40 1 2 3 4
5 6 7 8 95 6 7 8 9
-
8/2/2019 Intro to Comp Lec 3 Final 1
6/50
Binary (base 2) number systemBinary (base 2) number system
consists of just twoconsists of just two
0 10 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
7/50
Other popular number systemsOther popular number systems
OctalOctalbase = 8base = 8
8 symbols (0,1,2,3,4,5,6,7)8 symbols (0,1,2,3,4,5,6,7)
HexadecimalHexadecimalbase = 16base = 16
16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)16 symbols (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F)
-
8/2/2019 Intro to Comp Lec 3 Final 1
8/50
Decimal (base 10) numbers areDecimal (base 10) numbers are
expressed in the pexpressed in the positional notationositional notation
4202 = 2x104202 = 2x1000 + 0x10+ 0x1011 + 2x10+ 2x1022 + 4x10+ 4x1033
The right-most is the least significant digit
The left-most is the most significant digit
-
8/2/2019 Intro to Comp Lec 3 Final 1
9/50
Decimal (base 10) numbers areDecimal (base 10) numbers are
expressed in theexpressed in thepositional notationpositional notation
42042022 == 2x102x1000 + 0x10+ 0x1011 + 2x10+ 2x1022 + 4x10+ 4x1033
1s multiplier
1
-
8/2/2019 Intro to Comp Lec 3 Final 1
10/50
Decimal (base 10) numbers areDecimal (base 10) numbers are
expressed in theexpressed in thepositional notationpositional notation
42420022 == 2x102x1000 ++ 0x100x1011 + 2x10+ 2x1022 + 4x10+ 4x1033
10s multiplier
10
-
8/2/2019 Intro to Comp Lec 3 Final 1
11/50
Decimal (base 10) numbers areDecimal (base 10) numbers are
expressed in theexpressed in thepositional notationpositional notation
442202 = 2x1002 = 2x1000 + 0x10+ 0x1011 ++ 2x102x1022 + 4x10+ 4x1033
100s multiplier
100
-
8/2/2019 Intro to Comp Lec 3 Final 1
12/50
Decimal (base 10) numbers areDecimal (base 10) numbers are
expressed in theexpressed in thepositional notationpositional notation
44202202 == 2x102x1000 + 0x10+ 0x1011 + 2x10+ 2x1022 ++ 4x104x1033
1000s multiplier
1000
-
8/2/2019 Intro to Comp Lec 3 Final 1
13/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1001110011==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
The right-most is the least significant digit
The left-most is the most significant digit
-
8/2/2019 Intro to Comp Lec 3 Final 1
14/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1001100111==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
1s multiplier
1
-
8/2/2019 Intro to Comp Lec 3 Final 1
15/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1001001111==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
2s multiplier
2
-
8/2/2019 Intro to Comp Lec 3 Final 1
16/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1010001111==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
4s multiplier
4
-
8/2/2019 Intro to Comp Lec 3 Final 1
17/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1100011011==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
8s multiplier
8
-
8/2/2019 Intro to Comp Lec 3 Final 1
18/50
Binary (base 2) numbers areBinary (base 2) numbers are alsoalso
expressed in theexpressed in thepositional notationpositional notation
1100110011==1x21x200++1x21x211++0x20x222++0x20x233++1x21x244
16s multiplier
16
-
8/2/2019 Intro to Comp Lec 3 Final 1
19/50
CountingCounting
in Decimalin Decimal00
11
2233
44
55
66
77
88
99
10
11
1213
14
15
16
17
18
19
20
21
2223
24
25
26
27
28
29
30
31
3233
34
35
36
.
.
.
0
1
1011
100
101
110
111
1000
1001
1010
1011
11001101
1110
1111
10000
10001
10010
10011
10100
10101
1011010111
11000
11001
11010
11011
11100
11101
11110
11111
100000100001
100010
100011
100100
.
.
.
Counting
in Binary
?
-
8/2/2019 Intro to Comp Lec 3 Final 1
20/50
Why binaryWhy 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?
-
8/2/2019 Intro to Comp Lec 3 Final 1
21/50
bitbitbinary diginary digit
-
8/2/2019 Intro to Comp Lec 3 Final 1
22/50
Byte = 8 bitsByte = 8 bits
-
8/2/2019 Intro to Comp Lec 3 Final 1
23/50
Decimal Binaryconversion
-
8/2/2019 Intro to Comp Lec 3 Final 1
24/50
Convert 75 to BinaryConvert 75 to Binary752
37 12
18 12
9 02
4 12
2 02
1 02
0 1
1001011
remainder
-
8/2/2019 Intro to Comp Lec 3 Final 1
25/50
CheckCheck
10010111001011 == 1x21x200++1x21x211++0x20x222++1x21x233++
0x20x244++0x20x255++1x21x266
== 11 ++ 22 ++ 00 ++ 88 ++ 00 ++ 00 ++ 6464
== 7575
-
8/2/2019 Intro to Comp Lec 3 Final 1
26/50
Convert 100 to BinaryConvert 100 to Binary1002
50 02
25 02
12 12
6 02
3 02
1 12
0 1
1100100
remainder
-
8/2/2019 Intro to Comp Lec 3 Final 1
27/50
That finishes our first topic -That finishes our first topic - introductionintroduction toto
binary numbers and theirbinary numbers and theirconversionconversion toto
and from decimal numbersand from decimal numbers
Our next topic is Our next topic is
-
8/2/2019 Intro to Comp Lec 3 Final 1
28/50
Chapter Number 6Chapter Number 6
Boolean Algebra and Logic CirciutsBoolean Algebra and Logic Circiuts
-
8/2/2019 Intro to Comp Lec 3 Final 1
29/50
BooleanBooleanLogicLogic
OperationsOperations
-
8/2/2019 Intro to Comp Lec 3 Final 1
30/50
LetLet
xx,,yy,,zzbe Booleanbe Boolean
variables. Boolean variables canvariables. Boolean variables can
only have binary valuesonly have binary values i.e., they cani.e., they can
have values which are either 0 or 1have values which are either 0 or 1
For example, if we represent the state of aFor example, if we represent the state of a
light switchlight switch with a Boolean variablewith a Boolean variablexx, we, we
will assign a value of 0 towill assign a value of 0 toxx when thewhen the
switch is OFF, and 1 when it is ONswitch is OFF, and 1 when it is ON
-
8/2/2019 Intro to Comp Lec 3 Final 1
31/50
A few other names for the statesA few other names for the states
of these Boolean variablesof these Boolean variables0 1
Off On
Low High
False True
-
8/2/2019 Intro to Comp Lec 3 Final 1
32/50
We define the followingWe define the following logic operations orlogic operations or
functionsfunctions among the Boolean variablesamong the Boolean variables
Name Example Symbolically
NOT y = NOT(x) xAND z =x ANDy x y
OR z =x ORy x + y
XOR z =x XORy x y
-
8/2/2019 Intro to Comp Lec 3 Final 1
33/50
WellWell define these operationsdefine these operations with the help ofwith the help of
truth tablestruth tables
what is the truth tablewhat is the truth tableof a logic functionof a logic function
A truth table defines theA truth table defines the outputoutput of aof a
logic function forlogic function forallall possiblepossible inputsinputs
?
-
8/2/2019 Intro to Comp Lec 3 Final 1
34/50
Truth Table for theTruth Table for the NOTNOT OperationOperation
(y true whenever x is false)(y true whenever x is false)
x y = x
01
-
8/2/2019 Intro to Comp Lec 3 Final 1
35/50
Truth Table for theTruth Table for the NOTNOT OperationOperation
x y = x
0 11 0
-
8/2/2019 Intro to Comp Lec 3 Final 1
36/50
Truth Table for theTruth Table for theANDAND OperationOperation
(z true when both x & y true)(z true when both x & y true)
x y z = x y
0 00 1
1 01 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
37/50
Truth Table for theTruth Table for theANDAND OperationOperation
x y z = x y
0 0 00 1 0
1 0 01 1 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
38/50
Truth Table for theTruth Table for the OROR OperationOperation
(z true when x or y or both true)(z true when x or y or both true)
x y z = x + y
0 00 1
1 01 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
39/50
Truth Table for theTruth Table for the OROR OperationOperation
x y z = x + y
0 0 00 1 1
1 0 11 1 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
40/50
Truth Table for theTruth Table for the XORXOR OperationOperation
(z true when x or y true, but not both)(z true when x or y true, but not both)
x y z = x y0 00 1
1 01 1
-
8/2/2019 Intro to Comp Lec 3 Final 1
41/50
Truth Table for theTruth Table for the XORXOR OperationOperation
x y z = x y0 0 00 1 1
1 0 11 1 0
Those 4 were theThose 4 were the fundamentalfundamental logic operationslogic operations
-
8/2/2019 Intro to Comp Lec 3 Final 1
42/50
Those 4 were theThose 4 were the fundamentalfundamental logic operations.logic operations.
Here are examples of a few moreHere are examples of a few more complex situationscomplex situations
z =z = ((xx ++ yy))
z = yz = y
((xx++
yy))
z =z = ((yy xx)) ww
STRATEGY: Divide & Conquer
-
8/2/2019 Intro to Comp Lec 3 Final 1
43/50
x y x +y z = (x + y)
0 0 0 10 1 1 0
1 0 1 01 1 1 0
z =z = ((xx ++ yy))
-
8/2/2019 Intro to Comp Lec 3 Final 1
44/50
x y x + y z = y (x + y)
0 0 0 00 1 1 1
1 0 1 01 1 1 1
z = yz = y ((xx ++ yy))
-
8/2/2019 Intro to Comp Lec 3 Final 1
45/50
x y w y x z = (y x) w
0 0 0 0 00 0 1 0 1
0 1 0 0 0
0 1 1 0 11 0 0 0 0
1 0 1 0 1
1 1 0 1 1
z =z = ((yy xx)) ww
-
8/2/2019 Intro to Comp Lec 3 Final 1
46/50
Number of rows in a truth table?Number of rows in a truth table?
22nn
n = number of input variablesn = number of input variables
Assignment # 2Assignment # 2
-
8/2/2019 Intro to Comp Lec 3 Final 1
47/50
Assignment # 2Assignment # 2
A.A. Convert the following into binary numbers:Convert the following into binary numbers:i.i. TheThe last three digitslast three digits of your roll numberof your roll number
ii.ii. 256256
B.B. x, y & z are Boolean variables. Determinex, y & z are Boolean variables. Determine
thethe truth tablestruth tables for the followingfor the following
combinations:combinations:
i.i. ((x yx y))++ yy
ii.ii. ((xx yy))++ ww
Wh t h l t t d ?Wh t h l t t d ?
-
8/2/2019 Intro to Comp Lec 3 Final 1
48/50
What have we learnt today?What have we learnt today?
1.1.
About theAbout the binary number systembinary number system, and how it, and how itdiffersdiffers from the decimal systemfrom the decimal system
2.2. PositionalPositional notationnotation for representing binaryfor representing binary
and decimal numbersand decimal numbers
3.3. AA processprocess (or algorithm) which can be used(or algorithm) which can be usedtoto convertconvert decimal numbers to binarydecimal numbers to binary
numbersnumbers
4.4. BasicBasic logic operationslogic operations for Boolean variables,for Boolean variables,i.e. NOT, OR, AND, XOR, NOR, NAND,i.e. NOT, OR, AND, XOR, NOR, NAND,
XNORXNOR
Focus of the Next LectureFocus of the Next Lecture
-
8/2/2019 Intro to Comp Lec 3 Final 1
49/50
Focus of the Next LectureFocus of the Next Lecture
Next lecture will be theNext lecture will be the 3rd on Web dev3rd on Web dev
The focus of the oneThe focus of the one after that, the 10after that, the 10thth lecturelecture,,
however, will be onhowever, will be on softwaresoftware. During that. During thatlecture we will try:lecture we will try:
To understand theTo understand the role of software in computingrole of software in computing
To become able toTo become able to differentiatedifferentiate betweenbetween systemsystem
andand applicationapplication softwaresoftware
-
8/2/2019 Intro to Comp Lec 3 Final 1
50/50
QuestionsQuestions ????????????