0% found this document useful (0 votes)
5 views45 pages

CS110 4

The document provides an introduction to data representation in computing, emphasizing the importance of number systems such as decimal, binary, octal, and hexadecimal. It explains how data is processed in computers using these systems, detailing the conversion methods between them. Additionally, it covers the concepts of face value and position value in number representation.

Uploaded by

mambojoshua205
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)
5 views45 pages

CS110 4

The document provides an introduction to data representation in computing, emphasizing the importance of number systems such as decimal, binary, octal, and hexadecimal. It explains how data is processed in computers using these systems, detailing the conversion methods between them. Additionally, it covers the concepts of face value and position value in number representation.

Uploaded by

mambojoshua205
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/ 45

CS 110 – Introduction

To Computing

Module 4: Data Representation

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights Reserved.
May not be
Jennifer T. scanned,
Campbell,copied or duplicated,
Discovering or posted
Computers: Digital to a publicly Data,
Technology, accessible website,17th
and Devices, in whole or ©
Edition. in 2023
part. Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 1
Introduction

• We use computer to process the data and get the desired output.
• The data input can be in the form of alphabets, digits, symbols, audio,
video, magnetic cards, finger prints, etc.
• Since digital computer can only understand 0 and 1, the data must be
represented in the computer in 0s and 1s.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 2
Introduction

• Since data will be stored in using a number system, it is important to


study number systems that are used in the computer.
• The number systems discussed in this lecture are— (1) Decimal
number system, (2) Binary number system, (3) Octal number system,
and (4) Hexadecimal number system.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 3
Number System

• A number System is a writing system for expressing numbers, i.e., a


mathematical notation for representing numbers of a given set.
• A number system in base r uses unique symbols for r digits.
• One or more digits are combined to get a number.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 4
Number Systems

• The base of the number decides the valid digits that are used to
make a number.
• In a number, the position of digit starts from the right-hand side of
the number.
• The rightmost digit has position 0, the next digit on its left has
position 1, and so on.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 5
Number Systems

• The digits of a number have two kinds of values—


• Face value, and
• Position value.
• The face value of a digit is the digit located at that position. For
example, in decimal number 52, face value at position 0 is 2 and face
value at position 1 is 5.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 6
Number Systems

• The position value of a digit is (base position). For example, in decimal


number 52, the position value of digit 2 is 100 and the position value
of digit 5 is 101. Decimal numbers have a base of 10.

• The number is calculated as the sum of, face value * base position, of
each of the digits. For decimal number 52, the number is 5*101 + 2*100
= 50 + 2 = 52.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 7
Number Systems of interest

• Decimal Number System—Base 10


• Binary Number System—Base 2
• Octal Number System—Base 8
• Hexadecimal Number System—Base 16

A number in a particular base is written as (number)base of number. For


example, (23)10 means that the number 23 is a decimal number, and
(345)8 shows that 345 is an octal number.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 8
Decimal Number System

• I t consists of 10 digits—0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.


• All numbers in this number system are represented as combination of
digits 0–9. For example, 34, 5965 and 867321.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 9
Decimal Numbers

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 10
Octal Number System

• The octal number system consists of eight digits—0 to 7.


• All octal numbers are represented using these eight digits. For
example, 273, 103, 2375, etc.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 11
Octal Number System

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 12
Hexadecimal Number System

• The hexadecimal number system consists of sixteen digits—0 to 9, A,


B, C, D, E, F, where (A is for 10, B is for 11, C-12, D-13, E-14, F-15).
• All hexadecimal numbers are represented using these 16 digits.
• For example, 3FA, 87B, 113, etc.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 13
Hexadecimal Number System

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 14
Conversion from Decimal to Binary, Octal,
Hexadecimal
• A decimal number has two parts—integer part and fraction part.
• Eg. In the number 23.078, 23 is the integer part and 0.078 is the
fraction part.

• The method used for the conversion of the integer part of a decimal
number is different from the one used for the fraction part.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 15
Conversion from Decimal to Binary (Convert 25
from Base 10 to Base 2)
1. Make a table as
shown . Write the
number in centre
and to Base on the
left side.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 16
Converting 25 from base 10 to Base 2

2. Divide the number with to


Base. After each division,
write the remainder on
right-side column and
quotient in the next line in
the middle column.
Continue dividing till the
quotient is 0.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 17
Converting 25 from base 10 to base 2

3. Write the digits in


remainder column starting
from downwards to
upwards

The binary equivalent of


number (25)10 is (11001)2.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 18
Try

• Convert the following numbers from base 10 to base 2, 8 16

a) 53
b) 68
c) 29

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 19
Converting Decimal Fraction to other
bases
• A fractional number is a number less than 1.
• To convert a decimal fraction to—
• binary-multiply by 2,
• octal-multiply by 8, and,
• Hexadecimal-multiply by 16.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 20
Converting fractions (Steps)

• 1. Multiply the fractional number with the to Base, to get a resulting number.

• 2. The resulting number has two parts, non-fractional part and fractional part.

• 3. Record the non-fractional part of the resulting number.

• 4. Repeat the above steps at least four times.

• 5. Write the digits in the non-fractional part starting from upwards to downwards.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 21
Convert 0.2345 from Base 10 to
Base 2.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 22
Convert 0.2345 from Base 10 to Base 2.

• The binary equivalent of (0.2345)10 is (0.001111)2

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 23
Try

• Convert the following decimal fractions to base 2,8 and 16

a) 0.865
b) 0.455

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 24
Converting Decimal Integer. Fraction to
other bases
• The steps for conversion of a decimal fraction to any other base are—

• 1. Convert decimal integer part to the desired base following the


steps given earlier

• 2. Convert decimal fraction part to the desired base following the


steps shown earlier

• 3. The integer and fraction part in the desired base is combined


Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 25
Try

• Convert 34.4674 from Base 10 to Base 2.


• Convert 34.4674 from Base 10 to Base 8.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 26
Conversion of Binary, Octal, Hexadecimal
to Decimal
• Numbers have two parts—integer part and fraction part.
• The method used for the conversion of integer part and fraction part
of binary, octal or hexadecimal number to decimal number is the
same;
• multiplication operation is used for the conversion.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 27
Conversion of Binary, Octal, Hexadecimal
to Decimal (Steps)
1. Find the sum of the Face Value * (from Base) position for each digit in
the number.
a) In a non-fractional number, the rightmost digit has position 0 and the
position increases as we go towards the left.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 28
Conversion of Binary, Octal, Hexadecimal
to Decimal (Steps)
b. In a fractional number, the first digit to the left of decimal point has
position 0 and the position increases as we go towards the left.

• The first digit to the right of the decimal point has position –1 and it
decreases as we go towards the right (–2, –3, etc.)

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 29
Conversion of Binary, Octal, Hexadecimal
to Decimal (Steps)

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 30
Conversion of Binary, Octal, Hexadecimal
to Decimal (example)
• Convert 1011 from Base 2 to Base 10.
• 1011 = 1*23 + 0*22 + 1*21 + 1*20

• Convert C15 from Base 16 to Base 10.


• C15 = C*162 + 1*161 + 5*160
• = 12*256 + 1*16 + 5*1

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 31
Conversion of Binary, Octal, Hexadecimal
to Decimal (example)
• Convert .1101 from Base 2 to Base 10.
• .1101 = 1*2–1+ 1*2–2 + 0*2–3 + 1*2–4

• Convert .15 from Base 16 to Base 10.


• .15 = 1*16–1 + 5*16–2
• = 1/16 + 5/256 = 21/256 = 0.82

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 32
Conversion of Binary, Octal, Hexadecimal
to Decimal (example)
• Convert 1011.1001 from Base 2 to Base 10.
• 1011.1001 = 1*23 + 0*22 + 1*21 + 1*20 + 1*2–1 + 0*2–2 + 0*2–3 + 1*2–4
• = 8 + 0 + 2 + 1 + 1/2 + 0 + 0 + 1/16
• = 11+ 9/16 = 11.5625

• Convert 4D.21 from Base 16 to Base 10.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 33
Conversion of Binary to Octal, Hexadecimal

• A binary number can be converted into octal or hexadecimal number


using a shortcut method.
• The shortcut method is based on the following information —
i. An octal digit from 0 to 7 can be represented as a combination of 3
bits, since 23 = 8.
ii. A hexadecimal digit from 0 to 15 can be represented as a
combination of 4 bits, since 24 = 16.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 34
The Steps for Binary to Octal Conversion

• 1. Partition the binary number in groups of three bits, starting from


the right-most side.
• 2. For each group of three bits, find its octal number.
• 3. The result is the number formed by the combination of the octal
numbers.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 35
Binary to Octal Conversion (Example)

• Convert the binary number 1110101100110 to octal.


• Solution
• 1. Partition binary number in groups of three bits, starting from the
right-most side.
• 1 110 101 100 110

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 36
Binary to Octal Conversion (Example)

• 2. For each group find its octal number.


• 1 110 101 100 110
• 1 6 5 4 6

• 3. The octal number is 16546.

• Convert the binary number 1100111100111 to Octal

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 37
Steps for Binary to Hexadecimal

• 1. Partition the binary number in groups of four bits, starting from the
right-most side.
• 2. For each group of four bits, find its hexadecimal number.
• 3. The result is the number formed by the combination of the
hexadecimal numbers.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 38
Binary to Hexadecimal (Example)

• Convert the binary number 1110101100110 to hexadecimal


• Solution
• 1. Partition binary number in groups of four bits, starting from the
right-most side.
1 1101 0110 0110

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 39
Binary to Hexadecimal (Example)

• 2. For each group find its hexadecimal number.


1 1101 0110 0110
1 D 6 6

• 3. The hexadecimal number is 1D66.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 40
Conversion of Octal, Hexadecimal to Binary

• The conversion of a number from octal and hexadecimal to binary


uses the inverse of the steps defined for the conversion of binary to
octal and hexadecimal.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 41
Steps for Hexadecimal to Binary
Conversion
• 1. Convert each hexadecimal number into a four-digit binary number
moving from right to left.
• 2. The result is the number formed by the combination of all the bits.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 42
Conversion of Hexadecimal to Binary

• 1. Given number is 2BA3


• 2. Convert each hexadecimal digit into four digit binary number.
• 2 B A 3
• 0010 1011 1010 0011
• 3. Combine all the bits to get the result 0010101110100011.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 43
Steps for Octal to Binary Conversion

• 1. Convert each octal number into a three-digit binary number moving


from right to left.
• 2. The result is the number formed by the combination of all the bits.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 44
Conversion of Octal to Binary

• Convert the octal number 473 to binary.


• Solution
• 1. Given number is 473
• 2. Convert each octal digit into three digit binary number.
• 4 7 3
• 100 111 011
• 3. Combine all the bits to get the result 100111011.

Jennifer T. Campbell, Discovering Computers: Digital Technology, Data, and Devices, 17th Edition. © 2023 Cengage. All Rights
Reserved. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. 45

You might also like