0% found this document useful (0 votes)
10 views21 pages

Lecture 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views21 pages

Lecture 04

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Introduction to Information and

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

• Digit: A single numerical symbol used to form/represent numbers.


Or
It can be defined as: symbols to represent the magnitude of a quantity.
Example: 0,1,2,3,4,5,6,7,8,9
• Number:A combination/collection of one or more digits that
represent a value.
Example: 25 (formed using digits 2 and 5)
• Numbering system: A way of representing numbers.
• Each number system has:
1.A Base (Radix): Determines how many unique digits are used.
2.A Set of Digits: The symbols allowed in that system.
3.Place Value: Each digit’s position represents a power of the base.

4
Types of Number System

1. Decimal Number System (Base-10)


•Used by humans in daily life.
•Consists of 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

5
Positional Notation

•Positional notation (or place-value system) is a method of


representing numbers where the value of each digit depends on its
position in the number.
1.The rightmost digit has the least value (least significant digit),
and the leftmost has the highest value (most significant digit).
2.Each place value is a ”power of the base” (radix) of the number
system.

6
The Binary Numbering System

7
Positional Notation

Another EXAMPLE:
642 in base 10 positional notation is:

6 x 102 = 6 x 100 = 600


+ 4 x 101 = 4 x 10 = 40
+ 2 x 10º = 2 x 1 = 2 = 642 in base 10

The power indicates


the position of
the number
This number is in
base 10

8
Types of Number System

2-Binary Number System (Base-2)


•Used by computers and digital circuits.
•Consists of two digits: 0 and 1 (representing OFF and ON states).

9
Types of Number System

3. Octal Number System (Base-8)


•Used in older computer systems and UNIX file permissions.
•Consists of eight digits: 0, 1, 2, 3, 4, 5, 6, 7.

10
Types of Number System

4. Hexadecimal Number System (Base-16)


•Used in computer memory addressing, color codes (e.g., #FF0000
for red)..
•Consists of 16 symbols: 0-9 and A-F (where A=10, B=11, ..., F=15).

11
Why do we need different
Number Systems?

1.Computers work in binary but humans use decimal, so


conversion is needed.
2.Efficient data storage and processing (hexadecimal is
compact for memory addressing).
3.Different number systems suit different applications
(e.g., UNIX file permissions in octal).

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

Remember, the digit symbols in base 16 are


0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
3- Conversion between
Binary/Octal/Hexadecimal
 1st step is to convert
binary/octal/hexadecimal to
Decimal
 2nd step is to convert that decimal
into binary/octal/hexadecimal
More Conversions
 Decimal to Binary
 Decimal to Hexadecimal
 Decimal to Octal
 Binary to Decimal
 Binary to Hexadecimal
 Binary to Octal
 Octal to Binary
 Octal to Decimal
 Octal to Hexadecimal
 Hexadecimal to Binary
 Hexadecimal to Decimal
 Hexadecimal to Octal
HW: Practice examples of above scenarios

You might also like