Lecture 04
Lecture 04
Communication Technologies
Lecture # 4
Department of Computer Science
CUI Lahore Campus
The slides are adapted from the publisher’s material
Understanding Computers: Today and Tomorrow (Ch2)
&
Computer Science Illuminated (Chapter 2)
Data and Program Representation
Digital data
representation:
The process of
representing
data in digital form so it
can be
understood by a computer
2
Digital Data Representation
• Bit: The smallest unit of data that a
computer can recognize (a single 1 or 0)
Byte = 8 bits
Byte terminology used to
express the size of documents
and other files, programs, etc.
Prefixes are often used to
express larger quantities of
bytes: kilobyte (KB), megabyte
(MB), gigabyte (GB), terabyte
(TB), etc.
3
The Number System
4
Types of Number System
5
Positional Notation
6
The Binary Numbering System
7
Positional Notation
Another EXAMPLE:
642 in base 10 positional notation is:
8
Types of Number System
9
Types of Number System
10
Types of Number System
11
Why do we need different
Number Systems?
12
Number system conversions
1- Decimal to Binary/Octal/Hexadecimal
2- Binary/Octal/Hexadecimal to Decimal
3- Between Binary/Octal/Hexadecimal
13
1-Decimal to Binary/Octal/Hexadecimal
Converting Decimal to Binary
Example Scenario: A computer stores numbers in binary. If
you enter 75 in a program, it must be converted into binary
for processing.
Method: Repeated division by 2, recording the remainder
each time. 2 75
Result: Read from bottom to top → 1001011₂
2 37 1
75 = 1001011
2 18 1
2 9 0
2 4 1
2 2 0
1 0
Converting Decimal to Binary
(Float)
What is the Binary equivalent of the decimal
number 75.40?
2 75 75 = 1001011
=0.40 x 2 = 0.8
=0.80 x 2 = 1.6
2 37 1 =0.60 x 2 = 1.2
=0.20 x 2 = 0.4
2 18 1 0.40 = 0110
Pick the Integer Part until
2 9 0 term become 0 or for at
least 4 terms
2 4 1 75.40 = (1001011.0110)
2 2 0
1 0
2- Binary/Octal/Hexadecimal to Decimal
Converting Binary to Decimal
What is the decimal equivalent of the binary
number 1101110?
1 x 26 = 1 x 64 = 64
+ 1 x 25 = 1 x 32 = 32
+ 0 x 24 = 0 x 16 = 0
+ 1 x 23 = 1 x 8 = 8
+ 1 x 22 = 1 x 4 = 4
+ 1 x 21 = 1 x 2 = 2
+ 0 x 2º = 0 x 1 = 0
= 110 in base 10
Converting Binary to Decimal
(Float)
What is the decimal equivalent of the binary
number 10101.011?
Converting Octal to Decimal
What is the decimal equivalent of the octal
number 642?
6 x 82 = 6 x 64 = 384
+ 4 x 81 = 4 x 8 = 32
+ 2 x 8º = 2 x 1 = 2
= 418 in base 10
Converting Hexadecimal to
Decimal
What is the decimal equivalent of the
hexadecimal number DEF?
D x 162 = 13 x 256 = 3328
+ E x 161 = 14 x 16 = 224
+ F x 16º = 15 x 1 = 15
= 3567 in base 10