0% found this document useful (0 votes)
3 views

Data Representation

The document provides an overview of data representation in computer science, including number systems (binary, denary, hexadecimal), bit understanding, and conversion methods between these systems. It covers Binary Coded Decimal (BCD), binary addition and subtraction, signed and unsigned binary representation, and character encoding standards like ASCII and Unicode. Additionally, it discusses practical applications and the limitations of these encoding systems.

Uploaded by

fatimaraza853
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)
3 views

Data Representation

The document provides an overview of data representation in computer science, including number systems (binary, denary, hexadecimal), bit understanding, and conversion methods between these systems. It covers Binary Coded Decimal (BCD), binary addition and subtraction, signed and unsigned binary representation, and character encoding standards like ASCII and Unicode. Additionally, it discusses practical applications and the limitations of these encoding systems.

Uploaded by

fatimaraza853
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/ 77

DATA REPRESENTATION

COMPUTER SCIENCE 9618 PAPER 1


DATA REPRESENTATION

Data representation refers to the form in which data


is stored, processed and transmitted.

Number Systems

Binary (Base 2) 0 and 1

Denary (Base 10) 0123456789

Hexadecimal (Base 16) 0 1 2 3 4 5 6 7 8 9 A B C D E F

Understanding A Bit

A bit is the smallest unit of data in computing,


representing a binary state of 0 or 1. 8 bits are known
as a Byte. Each bit has a value and it depends how
many combination of 0 and 1 can be made by using
bits. For our questions we will be using a list which
you are suppose to memorize.

Memorized List

128 64 32 16 8 4 2 1
Case 1 : Positive Denary Number To Binary
Conversion

Question : Convert 65 into 8 bit Binary

Step 1 : Write down the memorized list

128 64 32 16 8 4 2 1

Step 2 : Put 1 on numbers which will be added to fulfil


Question Requirement and the rest will be 0

128 64 32 16 8 4 2 1

0 1 0 0 0 0 0 1
128 64 32 16 8 4 2 1

Ans : 0 1 0 0 0 0 0 1
Exam Style Question

Case 2 : Binary To Denary Conversion

Question : Convert the 8 bit binary number into denary

0 1 0 0 0 0 0 1

Step 1 : Write down the memorized list

0 1 0 0 0 0 0 1
128 64 32 16 8 4 2 1

Step 2 : Add only the numbers with 1

0 1 0 0 0 0 0 1
= 64 + 1 (Ans) 65

128 64 32 16 8 4 2 1
Exam Style Question
Hexadecimal

Why Do We Need Hexadecimal?

Computers operate using binary (base-2) number systems,


where all data is represented as a series of 0s and 1s.
However, binary numbers can become very long and hard to
read for humans. Hexadecimal is more compact and easier
to understand

Uses of Hexadecimal

Color Codes in Web Design #FFFFFF


Machine Code and Assembly Language
MAC Address

Hexadecimal (Base 16) 0 1 2 3 4 5 6 7 8 9 A B C D E F

Value Box

A 10

B 11

C 12

D 13

E 14

F 15
Case 3 : Binary Conversion To HexaDecimal

Question : Convert the 8 bit binary number into


Hexadecomal

1 1 0 1 1 0 0 1

Step 1 : From right side, divide binary number into groups of 4

1 1 0 1 1 0 0 1

Step 2 : Write the memorized list separately for each group

1 1 0 1 1 0 0 1

8 4 2 1 8 4 2 1

Step 3 : Add the number with and if the sum is greater than 9
then use Value Box

1 1 0 1 1 0 0 1

8 4 2 1 8 4 2 1

13 9
13 9
Value Box

A 10

B 11
According to value box the value 13
is D so the Final Answer would be
C 12

D 13

E 14
D9
F 15

Exam Style Question

Ans = F2
Case 4 : Denary To HexaDecimal

Question : Convert 195 to HexaDecimal.

Step 1 : First convert the denary number to Binary

128 64 32 16 8 4 2 1

1 1 0 0 0 0 1 1

128 64 32 16 8 4 2 1

Step 2 : Repeat the steps in Case 3

1 1 0 0 0 0 1 1

8 4 2 1 8 4 2 1

12 3

C3
Exam Style Question

Note : For Hexadecimal to Denary just consider each as


group of 4 and reverse the steps in case 4

4 E

0 1 0 0 1 1 1 0

8 4 2 1 8 4 2 1

0 1 0 0 1 1 1 0

After using the complete memorized link you will get 78


Binary Coded Decimal

Binary Coded Decimal (BCD) is a class of binary encodings


where each digit of a decimal number is represented by its
own binary sequence. In the most common form of BCD,
each of the decimal digits (0-9) is represented by a four-bit
binary number:

Uses of BCD

Any scenario where a single digit need to be transmitted /


displayed e.g Calculator and Digital Clocks.

0 0000

1 0001

2 0010

3 0011

4 0100

5 0101

6 0110

7 0111

8 1000

9 1001
Note : Any number greater than 9 can not be represented as
BCD 4bits

Case 1 : Denary to BCD

Question : Convert 54 into BCD

Step 1 : Each digit should be considered as an individual digit and


convert each digit into BCD format

5 4
0 1 0 1 0 1 0 0

Final answer would be 0101 0100

Exam Style Question

Final answer would be 0110 0101 0011


Case 2 : BCD to Denary

Question : Convert 0101 0100 into Denary

Step 1 : Make groups of 4

0 1 0 1 0 1 0 0

Step 2 : Write down the memorized list for each group and add

0 1 0 1 0 1 0 0
8 4 2 1 8 4 2 1

5 4
Final answer would be 54

Exam Style Question

Final answer would be 83


Question : Describe how denary integers larger than 9
can be converted into BCD. Give an example in your
answer.

Answer : Each denary digit is written as 4-Bit binary number


example 46 0100 0110

Question : Describe how an 8 bit BCD can be converted


into a denary integer. Give an example in your answer.

Answer : Binary Number is split into groups of 4 bits


starting from right. Each group of 4 bits is converted to
a denary digit.
example 0100 0110 will be 46

Question : Identify practical application where BCD is


used.

Answer : Any scenario where a single digit needs to be


transmitted / displayed
Example Caluclator and Digital Clocks
Binary Addition

Addition Sum Carry


0+0 0 0

0+1 1 0

1+0 1 0

1+1 0 1

1+1+1 1 1

Questions

0 1 1 1 1 1 1 0
1 0 1 1 1 1 1

1 1 0 0 1 1 1 0 1 1 1 1 1
1 1 0 0 1 1 1 1 1 1 1 0 1
Exam Style Question

Ans : 00110010

Ans : 11100001
Binary Magnitude

0 represents “Positive” 1 represents “Negative”

Binary Representation
Unsigned Binary Numbers : In this all bits contribute to the
magnitude of the number, and there is no concept of
negative numbers.

Signed Binary Numbers (Sign and Magnitude) : In a signed


binary number system 0 indicates a positive number. 1
indicates a negative number.

Two’s Compliment
To represent negative numbers we use a method Known as
Two’s compliment.

Positive Numbers : In two's complement, positive numbers


are represented just like unsigned binary numbers

Negative Numbers : Negative numbers are represented by


inverting all the bits of the positive number (known as
finding the one's complement) and then adding 1 to the
result.
Case 1 : Negative Denary Number To Binary
Conversion

Question : Convert -125 to Binary Form

Step 1 : Ignore negative sign and convert it to Binary

128 64 32 16 8 4 2 1

0 1 1 1 1 1 0 1

128 64 32 16 8 4 2 1

Step 2 : Apply Two’s Compliment

Steps to Find Two's Complement


1. Invert All Bits: Change all 0s to 1s and all 1s to 0s.
2. Add Binary 1

0 1 1 1 1 1 0 1
One’s Compliment

Two’s Compliment
0 1 1 1 1 1 0 1
One’s Compliment 1 0 0 0 0 0 1 0
Two’s Compliment 1
1 0 0 0 0 0 1 1

Exam Style Question

Ans : 1111 0011 1110

Note : All Two’s Compliment numbers that starts with 1 are


negative numbers.

Case 2 : Negative Two’s Compliment Binary To


Denary Conversion

Apply Two’s compliment and then use your memorized list


but make sure to put negative sign.
Exam Style Question

Ans
(i) 193
(ii) C1
(iii) -63
(iv) The first 4 bits would be 12 which is greater than 9 which
is not a valid BCD
Binary Subtraction

10 - 5 = 10 + (-5)

Note : Apply Two’s Compliment and then same working as


Binary Addition.

Exam Style Question

Converting 10 to -10 : 11110110


Adding : 00100011
11110110
Answer : 00011001
Concept Of Overflow

Computers have fixed memory spaces for eg 32 bits or 64 bit


so sometimes after calculation or after any arithmetic
operation the number of bits exceeds the maximum bits that
can be stored.

1 0 1 0 1 0 1 0

1 0 1 1 0 1 1 1

1 0 1 1 0 0 0 0 1
Question : State how an overflow can occur when adding two
binary integers

Answer : The result after adding two integers is larger


number than can be stored in the given number of bits
ASCII EXTENDED ASCII UNICODE

67 01000011

A ?

B ?

[] ?

Note : The numbers could easily be represented into Binary


Form but there was no way to represent alphabets / character

In the early days of computing, different manufacturers used


different character encodings, which made it difficult for
computers and devices from different companies to
communicate effectively. ASCII was developed to standardize
the encoding of text characters
Note : You are not suppose to memorize the list.
A = 65
a = 97

ASCII
7 bits
128 characters can be represented 0-127
American Standard Code For Information Interchange

Extended ASCII
8 bits
ASCII codes were 7 bit long but then it was extended to have
bit length of 8
256 characters can be represented
UNICODE

Problem which occurred after Extended ASCII was that we had


more characters which needed to be represented for Example
Arabic, Chinese, Greek Character as we had no representation
for these characters. It uses 16, 24, 32 Bits.

Question : What are the disadvantages if using ASCII codes ?

Answer :
Only 128 characters can be represented
uses value 0 to 127
Many characters used in other languages can not be
represented
In extended ASCII the characters from 128 to 255 may be
coded differently in different systems.

Question : How Unicode is designed to overcome the


disadvantages of ASCII ?

Answer :
Uses 16, 24, 32 bits
Unicode is designed to be superset of ASCII
Designed so the most characters in other languages can
be represented.
Exam Style Question

128
256

Each character has its ASCII codes. Those codes


are converted in binary format and are stored
together

Note : Binary Prefixes will be covered in multimedia


Data Representation
Question 1

Sir Taha Ali Papersdock +92 318 2248934


Question 2

Sir Taha Ali Papersdock +92 318 2248934


Question 3

Question 4

Sir Taha Ali Papersdock +92 318 2248934


Sir Taha Ali Papersdock +92 318 2248934
Question 5

Sir Taha Ali Papersdock +92 318 2248934


Question 6

Sir Taha Ali Papersdock +92 318 2248934


Question 7

Sir Taha Ali Papersdock +92 318 2248934


Sir Taha Ali Papersdock +92 318 2248934
Question 8

Sir Taha Ali Papersdock +92 318 2248934


Question 9

Sir Taha Ali Papersdock +92 318 2248934


Question 10

Sir Taha Ali Papersdock +92 318 2248934


Question 11

Sir Taha Ali Papersdock +92 318 2248934


Question 12

Sir Taha Ali Papersdock +92 318 2248934


Question 13

Sir Taha Ali Papersdock +92 318 2248934


Question 14

Sir Taha Ali Papersdock +92 318 2248934


Question 15

Sir Taha Ali Papersdock +92 318 2248934


Question 16

Sir Taha Ali Papersdock +92 318 2248934


Question 17

Sir Taha Ali Papersdock +92 318 2248934


9608 Topical Past Papers
Question 18

Question 19

Sir Taha Ali Papersdock +92 318 2248934


Question 20

Sir Taha Ali Papersdock +92 318 2248934


Question 21

Sir Taha Ali Papersdock +92 318 2248934


Question 22

Sir Taha Ali Papersdock +92 318 2248934


Question 23

Sir Taha Ali Papersdock +92 318 2248934


Question 24

Sir Taha Ali Papersdock +92 318 2248934


Question 25

Sir Taha Ali Papersdock +92 318 2248934


Question 26

Sir Taha Ali Papersdock +92 318 2248934


Question 27

Sir Taha Ali Papersdock +92 318 2248934


Question 28

Sir Taha Ali Papersdock +92 318 2248934


Question 29

Sir Taha Ali Papersdock +92 318 2248934


Question 30

Sir Taha Ali Papersdock +92 318 2248934


Question 31

Sir Taha Ali Papersdock +92 318 2248934


Question 32

Sir Taha Ali Papersdock +92 318 2248934


Answer
Answer 1

Answer 2

Sir Taha Ali Papersdock +92 318 2248934


Answer 3

Answer 4

Sir Taha Ali Papersdock +92 318 2248934


Answer 5

Answer 6

Answer 7

Sir Taha Ali Papersdock +92 318 2248934


Answer 8

Sir Taha Ali Papersdock +92 318 2248934


Answer 9

Answer 10

Sir Taha Ali Papersdock +92 318 2248934


Answer 11

Answer 12

Sir Taha Ali Papersdock +92 318 2248934


Answer 13

Sir Taha Ali Papersdock +92 318 2248934


Answer 14

Answer 15

Sir Taha Ali Papersdock +92 318 2248934


Answer 16

Sir Taha Ali Papersdock +92 318 2248934


Answer 17

Answer 18

Sir Taha Ali Papersdock +92 318 2248934


Answer 19

Answer 20

Answer 21

Sir Taha Ali Papersdock +92 318 2248934


Answer 22

Answer 23

Answer 24

Sir Taha Ali Papersdock +92 318 2248934


Answer 25

Answer 26

Sir Taha Ali Papersdock +92 318 2248934


Answer 27

Sir Taha Ali Papersdock +92 318 2248934


Answer 28

Sir Taha Ali Papersdock +92 318 2248934


Answer 29

Answer 30

Answer 31

Sir Taha Ali Papersdock +92 318 2248934


Answer 32

Sir Taha Ali Papersdock +92 318 2248934

You might also like