0% found this document useful (0 votes)
21 views264 pages

Chapter 1 - Data Representation

Chapter 1 discusses data representation in computer science, focusing on number systems, including binary, denary, and hexadecimal. It explains data storage units from bits to yottabytes, and the differences between kilobytes and kibibytes. The chapter also covers binary operations, including addition, subtraction, and logical shifts.
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)
21 views264 pages

Chapter 1 - Data Representation

Chapter 1 discusses data representation in computer science, focusing on number systems, including binary, denary, and hexadecimal. It explains data storage units from bits to yottabytes, and the differences between kilobytes and kibibytes. The chapter also covers binary operations, including addition, subtraction, and logical shifts.
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/ 264

CHAPTER 1:

1.1 DATA REPRESENTATION

1.1. NUMBER SYSTEMS


1.2 TEXT, SOUND AND IMAGES
1.3 DATA STORAGE AND
COMPRESSION

By: Noureddine Tadjerout


Learning Objectives
1.1 Number systems
Learning Objectives
1.1 Number systems
Learning Objectives
1.2 Text, sound and images
Learning Objectives
1.3 Data storage and compression
Learning Objectives
1.3 Data storage and compression
Why algorithms are called algorithm
https://www.youtube.com/watch?v=oRkNaF0QvnI
Why algorithms are called algorithm
COMPUTER SCIENCE
CHAPTER 1:

1.1 DATA REPRESENTATION

1.1 NUMBER SYSTEMS

By: Noureddine Tadjerout


Learning Objectives
1.1 Number systems
Learning Objectives
1.1 Number systems
Put these into Size Order – 30secs
Rank these types of data storage in
size
RAM

Hard Drive
Mr. Noureddine Tadjerout 14

1.1 Number systems


Measurement of the size of computer memories

9/24/2023
Mr. Noureddine Tadjerout 15

1.1 Number systems


The Difference Between Kilobytes and Kibibytes

This system is more accurate. Internal memories (such as RAM) should be measured using the IEC
system. A 64 GiB RAM could, therefore, store 64 × 230 bytes of data (68 719 476 736
bytes).

9/24/2023
Mr. Noureddine Tadjerout 16

1.1 Number systems


Bits, Bytes & Nibbles
Bit – e.g. 0
Each individual 1 or 0 is known as a bit.
Here are three bits – 110
Byte – e.g. 11001100
Each group of 8 bits is known as a Byte
Here is a stream of Bytes:
01010011 01101011 01111001 01110010 01101001 01101101 00100000 01101001
01110011 00100000 01100001 01110111 01100101 01110011 01101111 01101101
01100101 00100001

Nibble – e.g. 1111


A nibble is 4 bits, or half a Byte.
Here is a nibble – 1101

9/24/2023
Data Storage Capacities
Terabyte:
A Terabyte is a measure of computer storage capacity and is 2 to the 40th power of 1024
gigabytes.
Petabyte:
A Petabyte (PB) is a measure of memory or storage capacity and is 2 to the 50th power bytes or,
in decimal, approximately a thousand terabytes (1024 terabytes).
Exabyte:
An Exabyte (EB) is a large unit of computer data storage, two to the sixtieth power bytes. The
prefix exa means one billion, or on quintillion, which is a decimal term. Two to the sixtieth power
is actually 1,152,921,504,606,846,976 bytes in decimal, or somewhat over a quintillion (or ten to
the eighteenth power) bytes. It is common to say that an Exabyte is approximately one
quintillion bytes. In decimal terms, an Exabyte is a billion gigabytes.
Zettabyte:
A Zettabyte (ZB) is equal to one sextillion bytes. It is commonly abbreviated ZB. At this time, no
computer has one Zettabyte of storage. It has 1024 Exabytes.
Yottabyte:
A Yottabyte is equal to one septillion bytes. It is commonly abbreviated YB. At this time, no
computer has one Zettabyte of storage. It has 1024 Zettabytes.
How Computers Work – Binary!
 Computers are made up of complicated hardware that
stores and processes data.

 If you break a computer down into its most basic components


you have millions of circuits that either allow electricity to
flow, or not.

 Imagine a whole row of light switches that you can switch on


and off in different combinations to mean different things.

 Each switch is either on or off. It only has two states. That is


why everything stored in a computer can be stored as a
series of 1s and 0s. This is called binary.
CPU / Processor/ Chip
 The CPU is the brain of the computer – it tells the
computer what to do and when.

 Has millions of tiny switches that can either be:

on or off
1 or 0
1.1.1.1- Number System (Denary, also known as "decimal“)

0 , 1, 2, 3, 4, 5, 6, 7, 8, 9

 We use a number system that uses 10 different


numbers. (Base 10 number system)

 This is called the Denary System.

 However computers don’t understand this as they only


understand 0’s and 1’s.
on or off
Click this video that’s explains some of the core concepts behind computer
science :https://youtu.be/M41M9ATm49M
1.1 Number systems
A)-Converting from denary to binary
https://www.youtube.com/watch?v=rsxT4FfRBaM
Click the video below to learn to count in binary:
https://youtu.be/b7pOcU1xMks
1.1.Number System:
A)-Converting from denary to binary

 The position of numbers in binary is also important.


 Calculating denary number 1:

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

(1 * 1) = 1
1.1. Number System:
A)-Converting from denary to binary

 The position of numbers in binary is also important.


 Calculating denary number 3:

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

(1 * 2) = 2 + (1 * 1) = 1
1.1. Number System:
A)-Converting from denary to binary

 The position of numbers in binary is also important.


 Calculating denary number 6:

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

(1 * 4) = 4 + (1 * 2) = 2
1.1. Number System:
A)-Converting from denary to binary
 The position of numbers in binary is also important.
 Calculating denary number 37:

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

(1 * 32) = 32 +(1 * 4) = 4 + (1 * 1) = 1
1.1. Number System:
A)-Converting from denary to binary

 Can you work out how to write the denary number 115
in binary?
Denary 128 64 32 16 8 4 2 1
Binary 0 1 1 1 0 0 1 1

+ +
64 32 16 +2 +1
1.1. Number System:
A)-Converting from denary to binary

 Can you work out how to write the denary number 255
in binary?
Denary 128 64 32 16 8 4 2 1
Binary 1 1 1 1 1 1 1 1

+ + + + 8 + 4 +2 +1
128 64 32 16
1.1. Number System:
A)-Converting from denary to binary
 Work out the following numbers in binary:
Number Binary
165
117
61
224
39
139
170
186
255
223
84
Extension: Activity 1.1

Convert the following denary numbers into binary (using both


methods):
a: 42
b: 69
c: 88
d: 101
e: 112
f: 127
g: 146
h: 189
i: 204
Extension: IGCSE Exam Question 1
Extension: IGCSE Exam Question 2
IGCSE Exam Question 3
IGCSE Exam Answer 3
1.1. Number System:
B)-Converting from binary to denary or Decimal

https://www.youtube.com/watch?v=VLflTjd3lWA
Tip – Always use 8 bits for binary!
 So far we have only looked at numbers using eight
columns. This is an 8-bit number, or a byte.

 00000011 is binary for 3.

 You do not need the leading zeros for it to be a


valid number but we tend to write groups of 8 bits
because computers usually store data in bytes.
1.1. Number System:
B)-Converting from binary to denary or Decimal

Convert the following binary numbers into denary:


a: 0 0 1 1 0 0 1 1
b: 0 1 1 1 1 1 1 1
c: 1 0 0 1 1 0 0 1
d: 0 1 1 1 0 1 0 0
e: 1 1 1 1 1 1 1 1
f: 0 0 0 0 1 1 1 1
g: 1 0 0 0 1 1 1 1
h: 1 1 1 1 0 0 0 0
i: 0 1 1 1 0 0 0 0
j: 1 1 1 0 1 1 1 0
IGCSE Exam Question 1
Review
 What is binary? Explain this as if you are explaining this
to someone who knows nothing about it.
Mr. Noureddine Tadjerout 43

1.1 Number systems


Measurement of the size of computer memories
The Difference Between Kilobytes and Kibibytes
A kibibyte is the formal name for 1024 Bytes. It is “supposed” to be used instead of kilobyte for
this quantity, which according to SI naming conventions is supposed to be used for 1000
bytes. Kibibyte, Kilobyte.
In my experience, the “kibi” terms seem to be rarely used, as just about every computer person
other than some people on the net uses kilobyte to mean 1024 bytes and megabyte (or “meg”)
to be 1024^2 bytes (versus “mebibyte”, which I’ve seen even more rarely).
In practice, powers of 1024 bytes tend to end up being used for RAM, while powers of 1000
end up being used for selling hard disks and other persistent storage. Confusingly, file sizes in
bytes are also typically reported in terms of 1024 byte powers by most Unix/Linux file size
tools, such as “ls -lh”. (ls -lh. This command will show you the file sizes in human readable format)
Whenever I hear the word “kibibyte”, I think of this…

9/24/2023
Mr. Noureddine Tadjerout 44

1.1 Number systems


Measurement of the size of computer memories

9/24/2023
Mr. Noureddine Tadjerout 45

1.1 Number systems


The Difference Between Kilobytes and Kibibytes

This system is more accurate. Internal memories (such as RAM) should be measured using the IEC
system. A 64 GiB RAM could, therefore, store 64 × 230 bytes of data (68 719 476 736
bytes).

9/24/2023
1.1 Data Representation Mr. Noureddine Tadjerout 46

Number systems: Binary addition and subtraction


Click the link below to watch the video to How To Add and Subtract Binary Numbers:
https://www.youtube.com/watch?v=C5EkxfNEMjE

9/24/2023
Data Representation Mr. Noureddine Tadjerout 47

Number systems: Addition of binary numbers:


We will look at the addition of two 8-bit positive binary numbers.
Note the following key facts when carrying out addition of two binary digits:

9/24/2023
Data Representation Mr. Noureddine Tadjerout 48

Number systems: Addition of binary numbers:

9/24/2023
Data Representation Mr. Noureddine Tadjerout 49

Number systems: Addition of binary numbers:


Question 1:

9/24/2023
Data Representation Mr. Noureddine Tadjerout 50

Number systems: Binary addition and subtraction:

Question 2:

9/24/2023
Mr. Noureddine Tadjerout 51
1.1 Data Representation
Number systems: Binary addition and subtraction

Answer:

9/24/2023
Mr. Noureddine Tadjerout 52
1.1 Data Representation
Number systems: Logical binary shifts
Computers can carry out a logical shift on a sequence of binary numbers. The logical shift
means moving the binary number to the left or to the right. Each shift left is equivalent to
multiplying the binary number by 2 and each shift right is equivalent to dividing the binary
number by 2.

9/24/2023
Mr. Noureddine Tadjerout 53
1.1 Data Representation
Number systems: Logical binary shift: Left shift

9/24/2023
Mr. Noureddine Tadjerout 54
1.1 Data Representation
Number systems: Logical binary shift: Right shift

9/24/2023
Mr. Noureddine Tadjerout 55
1.1 Data Representation
Number systems: Logical binary shift: Left shift

9/24/2023
Mr. Noureddine Tadjerout 56
1.1 Data Representation
Number systems: Logical binary shift: Left shift

9/24/2023
Mr. Noureddine Tadjerout 57
1.1 Data Representation
Number systems: Logical binary shift: Left shift

9/24/2023
COMPUTER SCIENCE
CHAPTER 1:
1.1 DATA REPRESENTATION

1.1.2 Hexadecimal

By: Noureddine Tadjerout


Recap

 So if binary is a base 2 number system that has the


numbers 0 and 1.

 And denary (base 10) uses the numbers 0 , 1, 2, 3,


4, 5, 6, 7, 8, 9.

 How can we display numbers bigger than 9? For


example, 10, 11, 12, 13 etc?
Why hexadecimal?
 Hex numbers are shorter/more memorable than
equivalent binary numbers..

 ... and can easily be converted to and from


binary...

 ... as each hexadecimal digit corresponds to 4


binary digits
Which one is easier to remember?

 Humans are not very good at remembering long


strings of numbers.

 To make it easier for us, we can represent every


group of 4 bits (a nibble) with a single digit.
Hexadecimal
 Hexadecimal (or hex) is a base 16 system used to
simplify how binary is represented. A hex digit can
be any of the following 16 digits: 0 1 2 3 4 5 6 7 8
9 A B C D E F.
 Each hex digit reflects a 4-bit binary sequence.
 This table below shows each hex digit with the
equivalent values in binary and denary.
Hexadecimal

 Hexadecimal is a base 16 number system.


Denary Hexadecimal Denary Hexadecimal
0 0 10 A
1 1 11 B
2 2 12 C
3 3 13 D
4 4 14 E
5 5 15 F
6 6
7 7
8 8
9 9
Hexadecimal is a base 16 number system
Hexadecimal

 This means an 8-bit binary number can be written using


only two different hex digits - one hex digit for each
nibble (or group of 4-bits). It is much easier to write
numbers as hex than to write them as binary numbers.
 For example:
 11010100 in binary would be D4 in hex
 FFFF3 in hex would be 11111111111111110011 in
binary
Using hexadecimal
 Hex codes are used in many areas of computing to
simplify binary codes. It is important to note that
computers do not use hexadecimal - it is used by humans
to shorten binary to a more easily understandable form.
Hexadecimal is translated into binary for computer use.
Some examples of where hex is used include:
 colour references
 assembly language programs
 error messages
Using hexadecimal: Colours

 Hex can be used to represent colours on web pages and


image-editing programs using the format #RRGGBB (RR
= reds, GG = greens, BB = blues). The # symbol
indicates that the number has been written in hex format.
 This system uses two hex digits for each colour, eg
#FF6600.
Using hexadecimal: Colours
 Hex can be used to represent colours on web pages and image-
editing programs using the format #RRGGBB (RR = reds, GG =
greens, BB = blues). The # symbol indicates that the number has been
written in hex format.
 This system uses two hex digits for each colour, eg #FF6600.
Using hexadecimal: Colours
 As one hex digit represents 4 bits, two hex digits together
make 8 bits (1 byte). The values for each colour run between
00 and FF. In binary, 00 is 0000 0000 and FF is 1111 1111.
That provides 256 possible values for each of the three
colours.
 That gives a total spectrum of 256 reds x 256 greens x 256

blues - which is over 16 million colours in total.


 #FF0000 will be the purest red - red only, no green or blue.

 Black is #000000 - no red, no green and no blue.

 White is #FFFFFF.

spectrum mean is a band of colours


Using hexadecimal: Colours
 An orange colour can be represented by the code
#FF6600. The hex code is much easier to read than the
binary equivalent 1111 1111 0110 0110 0000 0000.
 If you are making a web page with HTML or CSS you
can use hex codes to choose the colours.
RGB colour model
 Hex values have equivalents in the RGB colour model.
The RGB model is very similar to the hex colour model,
but instead of combining hex values you use a value
between 0 and 255 for each colour. So an orange
colour that is #FF6600 in hex would be 255, 102, 0 in
RGB.
Memory dumps
 Since it is much easier to work with: B 5 A 4 1 A F C
 Rather than: 1 0 1 1 | 1 0 0 1 | 1 0 1 0 | 0 1 0 0 | 0 0 0 1 | 1 0 1 0 | 1 1 1 1 | 1 1 0 0
 Hexadecimal is often used when developing new software or when trying to
trace errors in programs. The contents of part of the computer memory can
hold the key to help solve many problems. When the memory contents are
output to a printer or monitor, this is known as a MEMORY DUMP.

Figure 1.1.2.1
Memory dumps
A program developer can look at each of the hexadecimal codes (as
shown in Figure 1.1.2.1 ) and determine where the error lies. The value
on the far left shows the memory location so that it is possible to find
out exactly where in memory the fault occurs.
This is clearly much more manageable using hexadecimal rather than
using binary. It’s a very powerful fault-tracing tool, but requires
considerable knowledge of computer architecture in order to interpret
the results.
Memory dumps
Click this video that’s explains What is a memory dump?
https://www.youtube.com/watch?v=bTOEIvZnAVQ
Memory dumps
Click this video How to Remove System Error Memory Dump Files on
Windows 10?
https://www.youtube.com/watch?v=JuWpa0ebyZc
Using hexadecimal: Errors
 Hex is often used in error messages on your computer.
The hex number refers to the memory location of the
error. This helps programmers to find and then fix
problems.
1.2 - Hexadecimal:

 Using the same method as denary and binary, this


gives the headings of 160, 161, 162, 163 and so on.
The typical headings for a hexadecimal number
with five digits would be:
1.1. Data Representation:
A)-Converting from Hexadecimal to Decimal or (Denary)

https://www.youtube.com/watch?v=pg-HEGBpCQk
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary)

 Hexadecimal Number FF to denary F = 15

Decimal 4096 256 16 1


Hexadecimal F F

((16 * 15) = 240) +((1 * 15) = 15))


(240 + 15 = 255)
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary)

 Hexadecimal Number 8D to denary D = 13

Decimal 4096 256 16 1


Hexadecimal 8 D

((16 * 8) = 128) +((1 * 13) = 13)


((128 + 13 = 141)
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary)

 On whiteboards convert EE to denary E = 14

Decimal 4096 256 16 1


Hexadecimal E E

(16 * 14) = 224 +(1 * 14) = 14


(224 + 14) = 238
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary)

 Convert 55AC to denary A = 10


C = 12

Decimal 4096 256 16 1


Hexadecimal 5 5 A C

(4096 * 5) + (256+5)+ (16 *10)+(1*12)


1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary
1.1. Data Representation
A)-Converting from Hexadecimal to Decimal or (Denary)
IGCSE Exam – Question 1
1.1. Data Representation
B)-Converting from Decimal To Hexadecimal
https://www.youtube.com/watch?v=QJW6qnfhC70
1.1. Data Representation
B)-Converting from Decimal To Hexadecimal
https://www.youtube.com/watch?v=4um7-QbpAQ8
Hexadecimal is a base 16 number system
1.1. Data Representation
B)-Converting from Decimal or Denary To Hexadecimal

Method 1: Convert the denary to binary first and then


convert the binary to hex as below:
Consider the conversion of the denary number, 2004, into
hexadecimal.
Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 1 1 1 1 1 0 1 0 1 0 0

7 D 4
Now look at Hexadecimal is a base 16 number table system above: you need to start from
the left to the right by dividing

01111 = 7 and 1101 = D and 0100 = 4


denary number = 2004, into hexadecimal = 7D4
1.1. Data Representation
B)-Converting from Decimal or Denary To Hexadecimal

 To verify our finding then we use the method 2 below :


Consider the conversion of the denary number, 2004, into
hexadecimal. This method
involves placing hexadecimal digits in the appropriate
position so that the total
Converting from hexadecimal to denary and from denary to hexadecimal
IGCSE Exam Question 1
IGCSE Exam Question 2
1.1. Data Representation
D)-Converting from Binary to Hexadecimal

https://www.youtube.com/watch?v=tSLKOKGQq0Y
1.1. Data Representation
D)-Converting from Binary to Hexadecimal

 Really you will only ever see 8-bit binary numbers at


IGCSE level, which can be represented as two hex
digits.

 The first hex digit represents groups of 16, the second


hex digit represents the units left over.

 denary = = in hex
5 12
(groups of 16) units
(replaced by C)
1.1. Data Representation
D)-Converting from Binary to Hexadecimal

Activity D
1.1. Data Representation
E)-Converting from Hexadecimal to Binary

https://www.youtube.com/watch?v=D_YC6DSPpQE
1.1. Data Representation
E)-Converting from Hexadecimal to Binary

Activity E
1.2 - Hexadecimal:
A)-Hexadecimal Addition

Click the link below to watch the video on


https://www.youtube.com/watch?v=y0B6tuC6niE
Hexadecimal is a base 16 number system
1.2 - Hexadecimal:
A)-Hexadecimal Addition
Example 1:
1.2 - Hexadecimal:
A)-Hexadecimal Addition
To double check your answer click in the link below:
https://www.calculator.net/hex-calculator.html
1.2 - Hexadecimal:
A)-Hexadecimal Addition
Example 2: Hex value: 8B + AA = 1 3 5
Hex value: 8B = 1000 1011 and Decimal value: 139
Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 1 0 0 0 1 0 1 1

Hex value: AA = 1010 1010 and Decimal value: 170


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 1 0 1 0 1 0 1 0

Hex value: 8B + AA = 1 3 5 and Decimal value: 139 + 170 = 309


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 1 0 0 1 1 0 1 0 1
1 3 5
1.2 - Hexadecimal:
A)-Hexadecimal Addition

To double check your answer click in the link below:


https://www.calculator.net/hex-calculator.html

Example 2:
1.2 - Hexadecimal:
A)-Hexadecimal Addition
Activity 1: Hexadecimal Calculation addition:
Hex value:
A+E=?
D+A=?
E7 + AB = ?
9F + CB = ?
A5 + EF = ?
99 + EE = ?
8B + AA =?
B2 + C7 = ?
A9 + E7 = ?
AC + EF = ?
2C + D4 = ?
1.2 - Hexadecimal:
B)-Hexadecimal Subtraction
Example 1: Hex value: 8B - 7A = 0 1 1
Hex value: 8B = 1000 1011 and Decimal value: 139
Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 1 0 0 0 1 0 1 1

Hex value: 7A = 0111 1010 and Decimal value: 122


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 0 1 1 1 1 0 1 0

Hex value: 8B – 7A = 11 and Decimal value: 139 - 122 = 17


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 0 0 0 1 0 0 0 1
0 1 1
1.2 - Hexadecimal:
B)-Hexadecimal Substraction
Activity 2: Hexadecimal Calculation Subtraction :
Hex value:
F-B=?
D-A=?
E6 – 3B = ?
C2 – A9= ?
5E – 1C = ?
D1 – 3F = ?
1A – 05 =?
AA – 11 = ?
BF – BB = ?
C9 – 2F = ?
24 – 12 = ?
1.2 - Hexadecimal:
B)-Hexadecimal Substraction
To double check your answer click in the link below:
https://www.calculator.net/hex-calculator.html
1.2 - Hexadecimal:
C)-Hexadecimal Multiplication
Example 2: Hex value: AA * A = 6A4
Hex value: AA = 1010 1010 and Decimal value: 170
Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 1 0 1 0 1 0 1 0

Hex value: A = 1010 and Decimal value: 10


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 0 0 0 0 0 0 0 1 0 1 0

Hex value: AA * A = 6A4 and Decimal value: 170 * 10 = 1700


Denary 1024 512 256 128 64 32 16 8 4 2 1

Binary 1 1 0 1 0 1 0 0 1 0 0
6 A 4
1.2 - Hexadecimal:
B)-Hexadecimal Multiplication
To double check your answer click in the link below:
https://www.calculator.net/hex-calculator.html
1.2 - Hexadecimal:
C)-Hexadecimal Multiplication
Activity 3: Hexadecimal Calculation Multiplication :
Hex value:
2×A=?
F×F=?
11 × C = ?
7D × 0A = ?
D8 × 6 = ?
32 × 12 = ?
B0 × 0C =?
EE × 9 = ?
DA × C = ?
FA × B = ?
99 × 9 = ?
Homework
 Complete the Sample question
USES OF HEXADECIMAL
The hex number is far easier for humans to remember, copy
and work with. This section reviews four uses of the
hexadecimal system:
 » error codes:

 » MAC addresses

 » IPv6 addresses

 » HTML colour codes


USES OF HEXADECIMAL
 Error codes are often shown as hexadecimal values. These numbers
refer to the memory location of the error and are usually automatically
generated by the computer.
 Media Access Control (MAC) address refers to a number which
uniquely identifies a device on a network. The MAC address refers to
the network interface card (NIC) which is part of the device. The MAC
address is rarely changed so that a particular device can always be
identified no matter where it is. A MAC address is usually made up of
48 bits which are shown as 6 groups of two hexadecimal digits
(although 64-bit addresses also exist):
 00 – 1C – B3 – 4F – 25 – FE is the MAC address of a device produced by the Apple
Corporation (code: 001CB3) with a serial number of: 4F25FE.
USES OF HEXADECIMAL
 Used in error messages
 https://www.bbc.co.uk/bitesize/guides/zp73wmn/revision/2#:~:text=H
ex%20is%20often%20used%20in,find%20and%20then%20fix%20prob
lems.

 Representation of colours in images and HTML

Challenge! – what other uses of hexadecimal in



computing can you find?
USES OF HEXADECIMAL
 Internet Protocol (IP) addresses:Each device connected to a network
is given an address known as the Internet
 Protocol (IP) address. An IPv4 address is a 32-bit number written in
denary or hexadecimal form: e.g. 109.108.158.1 (or 77.76.9e.01 in
hex). IPv4 has recently been improved upon by the adoption of IPv6.
An IPv6 address is a 128-bit number broken down into 16-bit chunks,
represented by a hexadecimal number.
 For example:

Note IPv6 uses a colon (:) rather than a decimal point (.) as used in IPv4.
HyperText Mark-up Language (HTML)

 HYPERTEXT MARK-UP LANGUAGE (HTML) is used when


writing and developing web pages. HTML isn’t a
programming language but is simply a mark-up
language. A mark-up language is used in the
processing, definition and presentation of text (for
example, specifying the colour of the text).
 HTML uses <tags> which are used to bracket a piece
of code; for example, <td> starts a standard cell in an
HTML table, and </td> ends it. Whatever is between
the two tags has been defined. Here is a short section
of HTML code:
HyperText Mark-up Language (HTML)

 HTML example:
HyperText Mark-up Language (HTML)

 HTML code is often used to represent colours of text


on the computer screen. The values change to
represent different colours. The different intensity of
the three primary colours (red, green and blue) is
determined by its hexadecimal value.
For example:
 • # FF 00 00 represents primary colour red

 • # 00 FF 00 represents primary colour green

 • # 00 00 FF represents primary colour blue


HyperText Mark-up Language (HTML)

1- Activity 1
Questions:
 Describe two applications of the hexadecimal system?
 Describe what is meant by HTML structure and
presentation for a web page?
Mr. Noureddine Tadjerout 122

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 1:

9/24/2023
Mr. Noureddine Tadjerout 123

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 2:

9/24/2023
Mr. Noureddine Tadjerout 124

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS ANSWER 2:

9/24/2023
Mr. Noureddine Tadjerout 125

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 3:

9/24/2023
Mr. Noureddine Tadjerout 126

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 4:

9/24/2023
Mr. Noureddine Tadjerout 127

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 4:

9/24/2023
Mr. Noureddine Tadjerout 128

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 4:

9/24/2023
Mr. Noureddine Tadjerout 129

1.1 DATA REPRESENTATION


IGCSE PAST PAPER 1 EXAMS QUESTION 5:

9/24/2023
1.1 Data Representation Mr. Noureddine Tadjerout 130

Number systems: One’s and Two’s Compliment


Up until now we have assumed all binary numbers have positive values. There are a number of
methods to represent both positive and negative numbers. We will consider:

• Signed Magnitude method


• one’s complement
• two’s complement.

It is not possible to add minus or plus symbol in front of a binary number because a binary
number can have only two symbol either 0 or 1 for each position or bit. That’s why we use this
extra bit called sign bit or sign flag. The value of sign bit is 1 for negative binary numbers
and 0 for positive numbers.
When an integer binary number is positive, the sign is represented by 0 and the magnitude by
a positive binary number. When the number is negative, the sign is represented by 1 but the
rest of the number may be represented in one of three possible ways: Sign-Magnitude
method, 1’s Complement method, and 2’s complement method. These are explained as
following below.

9/24/2023
1.1 Data Representation Mr. Noureddine Tadjerout 131

Number systems: One’s and Two’s Compliment


a). Signed Magnitude method

In this method, number is divided into two parts: Sign bit and Magnitude. If the number is
positive then sign bit will be 0 and if number is negative then sign bit will be 1. Magnitude is
represented with the binary form of the number to be represented.

Example 1: Let we are using 5 bits register. The representation of -5 to +5 will be as follows:

Most significant bit (MSB) and Least significant bit (LSB)

9/24/2023
1.1 Data Representation Mr. Noureddine Tadjerout 132

Number systems: One’s and Two’s Compliment


a). Signed Magnitude method

Example 1: Let we are using 4 binary bits register. The representation of -7 to +7 will be as
follows:

9/24/2023
1.1 Data Representation 133

Number systems: One’s and Two’s Compliment


b). One’s Complement Method:
Positive numbers are represented in the same way as they are represented in sign magnitude
method. If the number is negative then it is represented using 1’s complement. First represent the
number with positive sign and then take 1’s complement of that number.
In one’s complement, each digit in the binary number is inverted (in other words, 0 becomes 1
and 1 becomes 0).

For example 1: 01000110 (denary value 70) becomes 10111001 (denary value −70).

For example 2: Let we are using 5 bits register. The representation of -5 and +5 will be as
follows
1.1 Data Representation 134

Number systems: One’s and Two’s Compliment


c). Two’s Complement Method:
Positive numbers are represented in the same way as they are represented in sign magnitude
method. If the number is negative then it is represented using 2’s complement. First represent the
number with positive sign and then take 2’s complement of that number.
1.1 Data Representation 135

Number systems: One’s and Two’s Compliment


c). Two’s Complement Method:
Example 2: Let we are using 5 bits registers. The representation of -5 and +5 will be as follows:

+5 is represented as it is represented in sign magnitude method. -5 is represented using the


following steps:
(i) +5 = 0 0101
(ii) Take 2’s complement of 0 0101 and that is 1 1011. MSB is 1 which indicates that number
is negative.
MSB is always 1 in case of negative numbers
1.1 Data Representation 136

Number systems: One’s and Two’s Compliment


c). Two’s Complement Method:
Example 2: Let we are using 8 bits registers. The representation of -104 and +104 will be as
follows:

+104 128 64 32 16 8 4 2 1
Binary 0 1 1 0 1 0 0 0
1 comp 1 0 0 1 0 1 1 1
Opposite
Add 1 0 0 0 0 0 0 0 1
- 104 1 0 0 1 0 0 0 0
TWO'S COMPLEMENT 137

9/24/2023
TWO'S COMPLEMENT 138

WRITING NEGATIVE BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT AND CONVERTING TO DENARY

9/24/2023
TWO'S COMPLEMENT 139

WRITING NEGATIVE BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT AND CONVERTING TO DENARY

9/24/2023
TWO'S COMPLEMENT 140

WRITING NEGATIVE BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT AND CONVERTING TO DENARY

9/24/2023
TWO'S COMPLEMENT 141

WRITING NEGATIVE BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT AND CONVERTING TO DENARY

9/24/2023
TWO'S COMPLEMENT 142

WRITING NEGATIVE BINARY NUMBERS IN TWO’S COMPLEMENT FORMAT AND CONVERTING TO DENARY

9/24/2023
1.1 Data Representation Mr. Noureddine Tadjerout 143

Number systems: One’s and Two’s Compliment:


Watch the video for the Signed Binary (Sign and Magnitude & Two's Complement)
https://www.youtube.com/watch?v=sJXTo3EZoxM

9/24/2023
1.1 DATA REPRESENTATION Mr. Noureddine Tadjerout 144

WATCH THE VIDEO FOR THETWO’S COMPLEMENT REPRESENTATION OF A


SIGNED INTEGER
HTTPS://WWW.YOUTUBE.COM/WATCH?V=MRVCGIJXI9W

9/24/2023
Mr. Noureddine Tadjerout 145

1.1 DATA REPRESENTATION


NUMBER SYSTEMS: ONE’S AND TWO’S COMPLIMENT:
Convert the following negative Decimal number to binary

(- 49) = ?
(- 109) = ?
(- 107) = ?
(- 77) = ?
(- 17) = ?
( - 122) = ?
( - 38 ) = ?
( - 200 ) = ?
( -26 ) = ?
(-2) = ?
( -11) = ?
( - 52) = ?

9/24/2023
COMPUTER SCIENCE
CHAPTER 1:

1.1 DATA REPRESENTATION

1.2 TEXT, SOUND AND IMAGES

By: Noureddine Tadjerout


Learning Objectives
1.2 Text, sound and images
ASCII CODE

https://www.youtube.com/watch?v=H4l42nbYmrU
ASCII CODE Table :
ASCII CODE Table :
INTERNAL CODING OF NUMBERS 151

WATCH THE VIDEO FOR THE REPRESENTING TEXT IN BINARY (ASCII &
UNICODE)
HTTPS://WWW.YOUTUBE.COM/WATCH?V=TDMEXCDX-UC

9/24/2023 Mr. Noureddine Tadjerout


WATCH THE VIDEO FOR THE ASCII AND UNICODE CHARACTER SETS152
HTTPS://WWW.YOUTUBE.COM/WATCH?V=5AJKKGSEUNY

9/24/2023 Mr. Noureddine Tadjerout


ASCII AND UNICODE CHARACTER SETS 153

ASCII
THE ASCII CHARACTER SET IS A 7-BIT SET OF CODES THAT ALLOWS 128 DIFFERENT
CHARACTERS. THAT IS ENOUGH FOR EVERY UPPER-CASE LETTER, LOWER-CASE
LETTER, DIGIT AND PUNCTUATION MARK ON MOST KEYBOARDS. ASCII IS ONLY
USED FOR THE ENGLISH LANGUAGE.
THIS TABLE SHOWS SOME EXAMPLES OF LETTERS REPRESENTED USING THE ASCII
CHARACTER SET:

EXTENDED ASCII
EXTENDED ASCII CODE IS AN 8-BIT CHARACTER SET THAT REPRESENTS 256
DIFFERENT CHARACTERS, MAKING IT POSSIBLE TO USE CHARACTERS SUCH AS É OR
©. EXTENDED ASCII IS USEFUL FOR EUROPEAN LANGUAGES

9/24/2023 Mr. Noureddine Tadjerout


ASCII AND UNICODE CHARACTER SETS 154

CONSIDER THE UPPERCASE AND LOWERCASE CODES IN BINARY OF CHARACTERS. FOR EXAMPLE

ASCII code has a number of disadvantages. The main disadvantage is that it does not represent
characters in non-Western languages, for example Chinese characters. For this reason, different
methods of coding have been developed over the years. One coding system is called Unicode

Unicode can represent all languages of the world, thus supporting many operating systems,
search engines and internet browsers used globally.

9/24/2023 Mr. Noureddine Tadjerout


ASCII AND UNICODE CHARACTER SETS 155

UNICODE
UNICODE USES BETWEEN 8 AND 32 BITS PER CHARACTER, SO IT CAN REPRESENT
CHARACTERS FROM LANGUAGES FROM ALL AROUND THE WORLD. IT IS COMMONLY
USED ACROSS THE INTERNET. AS IT IS LARGER THAN ASCII, IT MIGHT TAKE UP MORE
STORAGE SPACE WHEN SAVING DOCUMENTS.

GLOBAL COMPANIES, LIKE FACEBOOK AND GOOGLE, WOULD NOT USE THE ASCII
CHARACTER SET BECAUSE THEIR USERS COMMUNICATE IN MANY DIFFERENT
LANGUAGES.

9/24/2023 Mr. Noureddine Tadjerout


1.2 Text, sound and images:
size Files
Text and numbers can be stored in a number of formats. Text is usually stored in an
ASCII format. If ASCII format is used to store text on a file, then the ASCII table is used to store each of the
characters. For example, the word COMPUTER would be stored as either: 67 79 77 80 85 84 69 82 or
%43 %4F %4D %50 %55 %54 %45 %52

(the first code is in denary and the second in hexadecimal).

Text files can also undergo file compression. These use complex algorithms that work on redundancy or
repeated sections of words (e.g. OU in yOUr, cOUntry or mOUntain). The following section shows, in very
simple terms, how this could work: The phrase ‘THIS SECTION SHOWS YOU HOW THIS WOULD WORK’
consists of 35 memory units (ignoring spaces). Repeated words, such as ‘THIS’ could be put into a data
dictionary and be replaced by ‘1’. Repeated word sections, such as ‘HOW’ and ‘OU’ could be replaced by
the numbers ‘2’ and ‘3’. Our phrase then becomes ‘1 SECTION S2S Y3 2 1 W3LD WORK’. Again, ignoring
spaces, this compressed form now uses only 23 memory units. This is about a 33% saving in file size.
Obviously if whole pages are to be stored, then repeated words and word sections become even more
numerous. Compression algorithms take many things into account when creating these compressed files – but
this is outside the scope of this textbook. This is clearly an example of lossless compression since the original
phrase can be reformed if necessary using the data dictionary and compressed file.
Noureddine Tadjerout
1.2 Text, sound and images:

How to estimate the size of a file


Estimating the size of a text file is relatively straightforward. In Chapter 1 we introduced the idea of ASCII code.
Each character from the keyboard has a value of 1 byte. Suppose we typed in the following message:
This is text from the computer science text book = 48 words = 48 bytes and then saved it under the filename
‘sample_text_for_book’. If we then looked at the properties of the file just saved, we would see:
1.2 Text, sound and images:

If we count the number of characters in the text typed in, we get the number 48. This exactly matches the file size
shown in the screenshot.
Earlier on in the chapter we looked at file sizes for photos and for sound. This is obviously a little more complex, but
we saw that one pixel, for example, occupies 3 bytes of memory. Suppose we imported the photograph shown
below:

Looking at the properties of the photograph, we


find this:

The photograph was 424 by 256 pixels which confirms the


file size of 325 632 bytes (318 kilobytes).
1.2 Text, sound and images: Mr. Noureddine Tadjerout 159

Sound :
Sound requires a medium in which to travel through (it cannot travel in a vacuum). This is because it
is transmitted by causing oscillations of particles within the medium. The human ear picks up these
oscillations (changes in air pressure) and interprets them as sound. Each sound wave has a
frequency and wavelength; the amplitude specifies the loudness of the sound.

9/24/2023
SOUND Mr. Noureddine Tadjerout 160

WATCH THE VIDEO FOR THE REPRESENTING SOUND IN BINARY


HTTPS://WWW.YOUTUBE.COM/WATCH?V=HLOTUCFTUV8 (4 MINUTES)

9/24/2023
1.2 TEXT, SOUND AND IMAGES: Mr. Noureddine Tadjerout 161

SOUND :
• SOUND ARISES FROM PRESSURE CHANGES

• SOUND IS AN IRREGULAR ANALOGUE WAVEFORM

• SOUND HAS TO BE SAMPLED TO BE STORED

• SAMPLING HAS A DEFINED SAMPLING RESOLUTION AND A DEFINED SAMPLING RATE

• A SOUND ENCODER CONTAINS A BAND-LIMITING FILTER AND AN ANALOGUE TO


DIGITAL CONVERTER

9/24/2023
© Cambridge University Press 2019
1.2 Text, sound and images: 162
Sound :
Sound is an analogue value; this needs to be digitized in order to store sound in a computer. This is
done using an analogue to digital converter (ADC). If the sound is to be used as a music file, it is
often filtered first to remove higher frequencies and lower frequencies which are outside the
range of human hearing. To convert the analogue data to digital, the sound waves are sampled at
a given time rate. The amplitude of the sound cannot be measured precisely, so approximate
values are stored.

What is Amplitude of Sound?


The amplitude of a sound wave is the measure of the height of the wave. The amplitude of a sound wave can
be defined as the loudness (Volume) or the amount of maximum displacement of vibrating particles of the
medium from their mean position when the sound is produced. It is the distance between the crest or trough and
the mean position of the wave and its measure in decibel (db),

9/24/2023
1.2 Text, sound and images: 163
Sound :
What is bandwidth of frequency?
Bandwidth is a range of frequencies within a continuous set of frequencies. It is measured in
Hertz (Hz). The purpose of a communication system is to transfer information from the
transmitter which is located in one place to a receiver which is usually far away from the
transmitter.

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 164
Sound :

Figure above shows a sound wave. The x-axis shows the time intervals when the sound was sampled (0 to 20),
and the y-axis shows the amplitude of the sampled sound (the amplitudes above 10 and below 0 are filtered
out in this example).

At time interval 1, the approximate amplitude is 9; at time interval 2, the approximate amplitude is 4, and so
on for all 20 time intervals. Because the amplitude range in Figure above is 0 to 10, then 4 binary bits can be
used to represent each amplitude value (for example, 9 would be represented by the binary value 1001).

Increasing the number of possible values used to represent sound amplitude also increases the accuracy of the
sampled sound (for example, using a range of 0 to 127 gives a much more accurate representation of the
sound sample than using a range of, for example, 0 to 10). This is known as the sampling resolution (also
known as the bit depth).

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 165
Sound :

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 166
Sound :

The benefits and drawbacks of using a larger sampling resolution when recording sound

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 167
Sound :

Sampling rate is the number of sound samples taken per second. The higher the sampling rate
and/or sampling resolution, the greater the file size. For example, a 16-bit sampling resolution is
used when recording CDs to give better sound quality.

Let's explore more about sampling by clicking the link below:

https://www.bbc.co.uk/bitesize/guides/z7vc7ty/revision/2

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 168

Images:
BIT-MAP IMAGES ARE MADE UP OF PIXELS (PICTURE ELEMENTS); THE IMAGE IS STORED IN A
TWO DIMENSIONAL MATRIX OF PIXELS.

9/24/2023
BITMAPS Mr. Noureddine Tadjerout 169

WATCH THE VIDEO FOR THE BITMAP IMAGES ( 6 MINUTES)


HTTPS://WWW.YOUTUBE.COM/WATCH?V=0KMIMFOALTI

9/24/2023
BITMAPS Mr. Noureddine Tadjerout 170

WATCH THE VIDEO FOR THE REPRESENTING IMAGES IN BINARY (5MINTES)


HTTPS://WWW.YOUTUBE.COM/WATCH?V=A3Y_ZVOR0K0

9/24/2023
Mr. Noureddine Tadjerout 171

IEC (INTERNATIONAL ELECTROTECHNICAL COMMISSION)

This system is more accurate. Internal memories (such as RAM and


ROM) should be measured using the IEC system. A 64 GiB RAM could,
therefore, store 64 × 230 bytes of data (68 719 476 736 bytes).

9/24/2023
BITMAPS Mr. Noureddine Tadjerout 172

CALCULATING BIT-MAP IMAGE FILE SIZES


IT IS POSSIBLE TO ESTIMATE THE FILE SIZE NEEDED TO STORE A BIT-MAP IMAGE. THE FILE SIZE WILL NEED
TO TAKE INTO ACCOUNT THE IMAGE RESOLUTION AND BIT DEPTH.

EXAMPLE 1: A FULL SCREEN WITH A RESOLUTION OF 1920 × 1080 PIXELS AND A BIT DEPTH OF 24
REQUIRES 1920 × 1080 × 24 BITS = 49 766 400 BITS FOR THE FULL SCREEN IMAGE

DIVIDING BY 8 GIVES US 6 220 800 BYTES (EQUIVALENT TO 6.222 MB USING THE SI UNITS OR 5.933 MIB
USING IEE UNITS). AN IMAGE WHICH DOES NOT OCCUPY THE FULL SCREEN WILL OBVIOUSLY RESULT IN A
SMALLER FILE SIZE.

NOTE: WHEN SAVING A BIT-MAP IMAGE, IT IS IMPORTANT TO INCLUDE A FILE HEADER; THIS WILL
CONTAIN ITEMS SUCH AS FILE TYPE (.BMP OR .JPEG), FILE SIZE, IMAGE RESOLUTION, BIT DEPTH (USUALLY
1, 8, 16, 24 OR 32), ANY TYPE OF DATA COMPRESSION EMPLOYED AND SO ON.

9/24/2023
BITMAPS Mr. Noureddine Tadjerout 173

CALCULATING BIT-MAP IMAGE FILE SIZES


EXAMPLE 2:

EXAMPLE 3:

9/24/2023
BITMAPS Mr. Noureddine Tadjerout 174

CALCULATING BIT-MAP IMAGE FILE SIZES


EXAMPLE 4:

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 175
Images:
VECTOR GRAPHICS ARE COMPUTER IMAGES CREATED USING A SEQUENCE OF COMMANDS OR
MATHEMATICAL STATEMENTS THAT PLACE LINES AND SHAPES IN A TWO-DIMENSIONAL OR THREE-
DIMENSIONAL SPACE. IN VECTOR GRAPHICS, A GRAPHIC ARTIST'S WORK, OR FILE, IS CREATED AND SAVED
AS A SEQUENCE OF VECTOR STATEMENTS.
A VECTOR GRAPHIC FILE DESCRIBES A SERIES OF POINTS TO BE CONNECTED.
THESE FILES ARE SOMETIMES CALLED GEOMETRIC FILES. IMAGES CREATED WITH TOOLS SUCH AS ADOBE
ILLUSTRATOR AND COREL'S COREL DRAW ARE USUALLY VECTOR IMAGE FILES.
SIMPLIFIED, VECTOR GRAPHICS ARE LIKE CONNECT-THE-DOTS DRAWINGS.

9/24/2023
1.2 Text, sound and images: Mr. Noureddine Tadjerout 176

Images:

9/24/2023
1.1 DATA REPRESENTATION

1.3 DATA STORAGE AND


COMPRESSION

By: Noureddine Tadjerout


Learning Objectives

1.3 Data storage and compression


Learning Objectives
1.3 Data storage and compression
1.3 DATA STORAGE AND COMPRESSIONMr. Noureddine Tadjerout 180

FILE FORMATS
IEC (INTERNATIONAL ELECTROTECHNICAL COMMISSION)

This system is more accurate. Internal memories (such as RAM and


ROM) should be measured using the IEC system. A 64 GiB RAM could,
therefore, store 64 × 230 bytes of data (68 719 476 736 bytes).

9/24/2023
Mr. Noureddine Tadjerout 181

1.3 DATA STORAGE AND COMPRESSION

The Calculations In Section 1.3.2 Show That Sound And Image Files Can Be Very Large. It Is Therefore
Necessary To Reduce (Or Compress) The Size Of A File For The Following Reasons:

» To Save Storage Space On Devices Such As The Hard Disk Drive/Solid State Drive.
» To Reduce The Time Taken To Stream A Music Or Video File.
» To Reduce The Time Taken To Upload, Download Or Transfer A File Across A Network.
» The Download/Upload Process Uses Up Network Bandwidth – This Is The maximum Rate Of Transfer Of
Data Across A Network, Measured In Bits Per Second. This Occurs Whenever A File Is Downloaded, For
Example, From A Server. Compressed Files Contain Fewer Bits Of Data Than Uncompressed Files And
Therefore Use Less Bandwidth, Which Results In A Faster Data Transfer Rate.
» Reduced File Size Also Reduces Costs. For Example, When Using Cloud Storage, the Cost Is Based On The
Size Of The Files Stored. Also An Internet Service Provider (ISP) May Charge A User Based On The Amount
Of Data Downloaded.

9/24/2023
1.3 Data storage and compression

Lossy and loss less file compression


Click the link below to watch the video for compression:
https://www.youtube.com/watch?v=29kUfFIlVJA

Noureddine Tadjerout
1.3 Data storage and compression

Lossy and loss less file compression

Noureddine Tadjerout
1.3 Data storage and compression

Lossy and loss less file compression


Click the link below to watch the video for Lossy and lossless compression methods:
https://www.youtube.com/watch?v=KJljOO48_vs

Noureddine Tadjerout
1.3 Data storage and compression

Lossy and loss less file compression

Noureddine Tadjerout
1.3 Data storage and compression

Lossy and lossless file compression


File compression can either be lossless or lossy.
Lossy file compression:
With this technique, the file compression algorithm eliminates unnecessary data from the file.
This means the original file cannot be reconstructed once it has
been compressed Lossy file compression results in some loss of detail when compared to the
original file. The algorithms used in the lossy technique have to decide which parts of the file
need to be retained and which parts can be discarded.

Example: When applying a lossy file compression algorithm to:

» an image, it may reduce the resolution and/or the bit/colour depth


» a sound file, it may reduce the sampling rate and/or the resolution.
Lossy files are smaller than lossless files which is of great benefit when considering storage
and data transfer rate requirements. Common lossy file compression algorithms are:
» MPEG-3 (MP3) and MPEG-4 (MP4)
Noureddine Tadjerout
» JPEG.
Lossless and lossy file compression
Lossless file compression
With LOSSLESS FILE COMPRESSION, all the data bits from the original file are
reconstructed when the file is again uncompressed. This is particularly
important for files where loss of any data would be disastrous – for example,
a spreadsheet file.
Lossy file compression
LOSSY FILE COMPRESSION is very different to lossless file compression. With
this technique, the file compression algorithm eliminates unnecessary bits of
data as seen in MP3 and jpeg formats.
It is impossible to get the original file back once it is compressed. This is why
it is chosen for files where removing certain bits doesn’t detract from the
quality.

Noureddine Tadjerout
1.3 Data storage and compression

 A number of different file formats are used in computer


systems. We will look at the following ones:
• Musical Instrument Digital Interface (MIDI)
• MP3
• MP4
• jpeg
• text and number format.

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)


https://www.youtube.com/watch?v=BAAVCPlJuhY

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)


MPEG-3 (MP3) uses technology known as AUDIO COMPRESSION to
convert music and other sounds into an MP3 file format. Essentially, this
compression technology will reduce the size of a normal music file by
about 90 per cent. For example, an 80 megabyte music CD can be
reduced to 8 megabytes using MP3 technology.
MP3 files are used in MP3 players, computers or mobile phones.
How can the original music file be reduced by 90 per cent whilst still
retaining most of the music quality? This is done using file compression
algorithms which use PERCEPTUAL MUSIC SHAPING; this essentially
removes sounds that the human ear can’t hear properly. For example, if
two sounds are played at the same time, only the louder one can be heard
by the ear, so the softer sound is eliminated.

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)


MP3 files use what is known as a LOSSY FORMAT, this means that the
original file can’t be put back together again. However, even the quality
of MP3 files can be different since it depends on the BIT RATE – this is the
number of bits per second used when creating the file. Bit rates are
roughly between 80 and 320 kilobits per second; usually 200 or higher
gives a sound quality close to a normal CD.

MPEG-4 (MP4) files are slightly different to MP3 files. This format allows
the storage of multimedia files rather than just sound. Music, videos, photos
and animation can all be stored in the MP4 format. Videos, for example,
could be streamed over the internet using the MP4 format without losing
any real discernable quality.

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)


https://www.youtube.com/watch?v=MmecPiKClHk

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)

Noureddine Tadjerout
1.3 Data storage and compression

MPEG-3 (MP3) and MPEG-4 (MP4)

Noureddine Tadjerout
1.3 Data storage and compression

Joint Photographic Experts Group (jpeg) files)


https://www.youtube.com/watch?v=Ba89cI9eIg8

Noureddine Tadjerout
1.3 Data storage and compression

Joint Photographic Experts Group (jpeg) files)


Look at the following five photographs of the same car wheel:

The resolution of the photographs is reduced from A to E. Photographs A and B are very
sharp whilst photograph D is very fuzzy and E is almost unrecognizable. This is the result
of changing the number of PIXELS per centimeter used to store the image (that is,
reducing the PICTURE RESOLUTION).
When a photographic file undergoes file compression, the size of the file is reduced.
When file size is reduced then quality of the image will reduce . One of the file formats
used to reduce photographic file sizes is known as JPEG.

Noureddine Tadjerout
1.3 Data storage and compression

Joint Photographic Experts Group (jpeg) files)

Noureddine Tadjerout
1.3 Data storage and compression

Joint Photographic Experts Group (jpeg) files)


This is another example of lossy file compression. Jpeg will reduce the RAW BITMAP image
by a factor of between 5 and 15 depending on the quality of the original.
An image that is 2048 pixels wide and 1536 pixels high is equal to 2048 × 1536 pixels;
in other words, 3 145 728 pixels. This is often referred to as a 3-megapixel image
(although it is obviously slightly larger). A raw bitmap can often be referred to as a TIFF or
BMP image (file extension .TIF or .BMP). The file size of this image is determined by the
number of pixels. In the previous example, a 3-megapixel image would be 3 megapixels ×
3 colours. In other words, 9 megabytes (each pixel occupies 3 bytes because it is made up
of the three main colours: red, green and blue). TIFF and BMP are the highest image
quality because, unlike jpeg, they are not in a compressed format.
The same image stored in jpeg format would probably occupy between 0.6 megabytes
and 1.8 megabytes.

Noureddine Tadjerout
1.3 Data storage and compression

Lossless file compression


With this technique, all the data from the original uncompressed file can be reconstructed. This
is particularly important for files where any loss of data would be disastrous (e.g. when
transferring a large and complex spreadsheet or when downloading a large computer
application).
Lossless file compression is designed so that none of the original detail from the file is lost.

Noureddine Tadjerout
1.3 Data storage and compression

Lossless and lossy file compression

Noureddine Tadjerout
1.3 Data storage and compression

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Exam Question:1

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Exam Question:1

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Exam Question:1

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Exam Answer:1

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Exam Question:2

Noureddine Tadjerout
1.3 Data storage and compression

IGCSE past paper Answer:2

Noureddine Tadjerout
1.3 DATA STORAGE AND COMPRESSION 209

RUN-LENGTH ENCODING (RLE)


Run–length encoding (rle) is a simple form of lossless data compression that runs on sequences
with the same value occurring many consecutive times. it encodes the sequence to store only a
single value and its count. for example, consider a screen containing plain black text on a solid
white background.

What is rle used for?


rle is particularly well suited to palette-based bitmap images such as computer icons, and was
a popular image compression method on early online services such as compuserve before the
advent of more sophisticated formats such as gif

Example: the sequence of data is stored as a single value and count. for example, for a minute
of a scene filmed at a beach there would be similar colours on screen for the duration of the
shot, such as the blues of the sky and the sea, and the yellows of the sand.

9/24/2023 Mr. Noureddine Tadjerout


1.3 DATA STORAGE AND COMPRESSION 210

WATCH THE VIDEO FOR RUN-LENGTH ENCODING (RLE) (6 MINUTES)


HTTPS://WWW.YOUTUBE.COM/WATCH?V=CAAESN8_ACU
HTTPS://WWW.CSFIELDGUIDE.ORG.NZ/EN/CHAPTERS/CODING-
COMPRESSION/RUN-LENGTH-ENCODING/

9/24/2023 Mr. Noureddine Tadjerout


1.3 DATA STORAGE AND COMPRESSION 211

WATCH THE VIDEO FOR RUN-LENGTH ENCODING (RLE) (6 MINUTES)


HTTPS://YOUTU.BE/UAV2RUAJTJQ

9/24/2023 Mr. Noureddine Tadjerout


1.3 Data storage and compression
Run-length encoding (RLE)

Noureddine Tadjerout
1.3 Data storage and compression
Run-length encoding (RLE)

Noureddine Tadjerout
1.3 Data storage and compression
Run-length encoding (RLE)

Noureddine Tadjerout
1.3 Data storage and compression
Run-length encoding (RLE)

Noureddine Tadjerout
Question 1
Answer 1
Question 2
Question 2
Exam: Answer 2
Answer 2
Question 3
Answer 3
Question 4
Question 4
Question 4
Answer 4
Question 5
Question 5
Question 5
Answer 5
Answer 5
Answer 5
Question 6
Question 6
Answer 6
Question 7
Question 7
Question 7
Answer 7
Answer 7
Question 8
Question 8
Question 8
Question 8
Answer 8
Answer 8
Question 9
Question 9
Question 9
Answer 9
Answer 9
Question 10
Question 10
Question 10
Answer 10
Answer 10
Question 11
Question 11
Question 11
Answer 11
Answer 11
Question and Answer 12:
Question and Answer 13:
Question and Answer 14:
Question and Answer 15:

You might also like