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

Chapter 1 - Data Representation

The document provides an overview of data representation in computers. It discusses how computers use binary numbering systems with digits of 0 and 1 to represent all data, rather than the base-10 decimal system used by humans. It covers converting between binary, decimal, and hexadecimal numbering systems. Key learning objectives are understanding how binary numbers represent data and how different data types like text, images, sound and video are stored as binary files.

Uploaded by

MOG FBUI
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)
315 views

Chapter 1 - Data Representation

The document provides an overview of data representation in computers. It discusses how computers use binary numbering systems with digits of 0 and 1 to represent all data, rather than the base-10 decimal system used by humans. It covers converting between binary, decimal, and hexadecimal numbering systems. Key learning objectives are understanding how binary numbers represent data and how different data types like text, images, sound and video are stored as binary files.

Uploaded by

MOG FBUI
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/ 48

Computer Science

Cambridge, IGCSE
Chapter 1 – Data Representation

Computer Science, IGCSE


Data representation
Learning Objectives
• Understand how binary numbers are used by computer systems
• Convert between denary and binary numbers
• Convert between denary and hexadecimal numbers
• Convert between binary and hexadecimal numbers
• Understand the use of hexadecimal notation
• Understand how chars, images, video and audio are stored as binary
• Understand how data is compressed using lossy and lossless
compression methods

Computer Science, IGCSE


Data Representation
• Data is information coded in a format ready for processing. Data is raw facts and figures in the
form of numbers, symbols or A/N characters

• Analogue data (humans) vs Digital data (computers)

• Analogue data is data that is transmitted or received continuously by our senses (sight and sound)
• A sound waves (music) received over a period
• Everything we see
• As humans we can process and understand it
• Computers cannot process analogue data – they can only process digital data
• Any data we want the computer to process must first be converted into digital data

• Digital data is data that consists of individually recognizable binary digits – 0’s and 1’s
• A sound wave would be sampled at set time intervals and converted into a stream of binary digits

Computer Science, IGCSE


Denary vs Binary
• Denary
• This is what we use in our daily lives
• Uses digits 0 – 9 and is called a base-10 number system
• The units it uses increase by the power of 10
• Example: the number 123 equates to
• 3 * 10 power of 0 = 3 +
• 2 * 10 power of 1 = 20 +
• 1 * 10 power of 2 = 100
• Denary placeholders – each bucket can only hold numbers 0 to 9
• Example 9 999
10 power 3 10 power 2 10 power 1 10 power 0

Largest number 9 * 1000 Largest number 9 * 100 Largest number 9 * 10 Largest number 9 * 1
Computer Science, IGCSE
Denary vs Binary
• Binary
• This is what computers use
• Uses digits 0 – 1 and is called a base-2 number system
• The binary value represents the current flowing through a circuit
• 1 means its flowing
• 0 means its not
• The units it uses increase by the power of 2
• Example: the binary number 1010 equates to 10 in Denary
• 0 * 2 power of 0 = 0 +
• 1 * 2 power of 1 = 2 +
• 0 * 2 power of 2 = 0 +
• 1 * 2 power of 3 = 8

Computer Science, IGCSE


Denary vs Binary
10 power 3 10 power 2 10 power 1 10 power 0

Largest number 9 * 1000 Largest number 9 * 100 Largest number 9 * 10 Largest number 9 * 1

2 power 3 2 power 2 2 power 1 2 power 0

Largest number 1 * 8 Largest number 1 * 4 Largest number 1 * 2 Largest number 1 * 1

Computer Science, IGCSE


Data Representation – binary to decimal
128 64 32 16 8 4 2 1
2/7 2/6 2/5 2/4 2/3 2/2 2/1 2 power 0
1 0 1 0
0 1 0 1 1 0 0 1

Binary 1010 = Decimal (8 + 0 + 2 + 0) 10

Binary 01011001 = Decimal (0 + 64 + 0 + 16 + 8 + 0 + 0 + 1) 89

Binary 00110011 = Decimal ?

Binary 11001100 = Decimal ?

Binary 11110001 = Decimal ?


Computer Science, IGCSE
Data Representation – decimal to binary
Convert decimal 150 to Binary
128 64 32 16 8 4 2 1
2/7 2/6 2/5 2/4 2/3 2/2 2/1 2 power 0
1

128 64 32 16 8 4 2 1
2/7 2/6 2/5 2/4 2/3 2/2 2/1 2 power 0
1 0

128 64 32 16 8 4 2 1
2/7 2/6 2/5 2/4 2/3 2/2 2/1 2 power 0
1 0 0 1 0 1 1 0

Decimal 150 = Binary 10010110 Decimal 44 = Binary ? Decimal 248 = Binary ? Decimal 250 = Binary ?
Computer Science, IGCSE
Beyond 8-bit binary
• Apply the same principles to convert beyond eight bits by simply
using further binary units beyond 128
• Example
2048 1024 512 256 128 64 32 16 8 4 2 1
1 0 1 1 0 0 1 0 1 1 0 1

Equals 2861 denary

What would the binary 1001100110011001 equate to in denary?

Computer Science, IGCSE


Hexadecimal number system
• Hexadecimal
• Hexadecimal uses 16 symbols, digits 0 – 9 and letters A – F and is called a base-16
number system
• A – F is used because only 1 symbol can be used for each unit, and 10 has 2 units – so
A is used

Dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F
Hex

• The units it uses increase by the power of 16


• Example: the hexadecimal number C9 equates to 201 in Denary
• 9 * 16 power of 0 = 9 +
• 12 * 16 power of 1 = 192

Computer Science, IGCSE


Denary vs Binary vs Hexadecimal
10 power 3 10 power 2 10 power 1 10 power 0

Largest number 9 * 1000 Largest number 9 * 100 Largest number 9 * 10 Largest number 9 * 1

2 power 3 2 power 2 2 power 1 2 power 0

Largest number 1 * 8 Largest number 1 * 4 Largest number 1 * 2 Largest number 1 * 1

16 power 3 16 power 2 16 power 1 16 power 0

Largest number 15 * 4096 Largest number 15 * 256 Largest number 15 * 16 Largest number 15 * 1

Computer Science, IGCSE


Decimal to hexadecimal conversion
Convert decimal 55 to Hexadecimal
65 336 4096 256 16 1
16 / 7 16 / 6 16 / 5 16 / 4 16 / 3 16 / 2 16 / 1 16 power 0

65 336 4096 256 16 1


16 / 7 16 / 6 16 / 5 16 / 4 16 / 3 16 / 2 16 / 1 16 power 0

65 336 4096 256 16 1


16 / 7 16 / 6 16 / 5 16 / 4 16 / 3 16 / 2 16 / 1 16 power 0
3 7

Decimal 1080 in hexadecimal? Decimal 101 in hexadecimal? Decimal 20 in hexadecimal?


Computer Science, IGCSE
Hexadecimal to decimal conversion
Convert Hexadecimal F9 to decimal
65 336 4096 256 16 1
16 / 7 16 / 6 16 / 5 16 / 4 16 / 3 16 / 2 16 / 1 16 power 0

65 336 4096 256 16 1


16 / 7 16 / 6 16 / 5 16 / 4 16 / 3 16 / 2 16 / 1 16 power 0
F 9

Hex 9 = 9 * 16 power 0 = 9 +
Hex F = 15 * 16 power 1 = 240
Answer is 249

hexadecimal 1080 in decimal ? hexadecimal 101 in decimal? hexadecimal 20 in decimal?


Computer Science, IGCSE
Converting between hexadecimal and binary
Den 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Hex
D 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 A
10 B
11 C
12 D
13 E
14 F
15

Convert Binary and Hexadecimal:


- Group Binary into groups of 4 bits – called nibbles
- Convert Binary to Decimal
- Convert Decimal to Hexadecimal
Method works both ways Binary ßà Hexadecimal

Binary Hexadecimal
101111001001 à 11 12 9 BC9 to decimal: 11 12 9
B C 9
To binary 101111001001
Hexadecimal: BC9
Computer Science, IGCSE
Tasks
• Question 1: A stopwatch displays Hours Minute and Seconds (3 marks)
0 1: 5 4 :2 3

Uses a nibble of binary data for each digit displayed


What time does the stopwatch show if the binary nibbles contain?

0000 0010: 0011 1000: 0101 1001


• Question 2: Convert the following binary code into hexadecimal (3 marks)
110000011110
Question 3: Convert hexadecimal number 3AD to binary and to denary (6 marks)
Question 4A: A digital speedometer has each digit represented by a 4-bit register e.g., Speedometer speed of 129 is shown in the registers as

0 0 0 1
What values must be in the 4-bit registers
0 0 1 0 to represent a speed of 074?
1 0 0 1
Computer Science, IGCSE
Tasks
Question 4B: What does the speedometer show if the 4-bit registers contain the following

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

Question 5: Convert hexadecimal number B 0 F into denary

Question 6: Convert denary number 3000 into hex notation

Computer Science, IGCSE


Data Representation
• Measuring Memory Size
• A byte is a unit of data that is 8 binary digits (bits) long
• A byte can represent a character e.g., a letter, a number or a symbol.
• It can also hold a string of bits that can be used to build an image, for example
• Computer storage is measured in multiples of bytes (B)
• A bit (b) is 1/8th of a byte
Unit of Measurement Abbreviation Conversion
Byte B 8 bits (b)
Kilobyte Kibibyte kB 1000 1024 bytes
Megabyte Mebibyte MB 1000 1024 kB
Gigabyte GIbibyte GB 1000 1024 MB
Terabyte Tebibyte TB Computer Science, IGCSE
1000 1024 GB
Data Representation
• Using binary in computer registers (for applications like robotics, digital
instruments and counting systems)

• Definition of a register: a small piece of memory where values can be held


temporarily

• A register is a small piece of memory built into the CPU (Central Processing Unit) of a
computer system, where values and instructions are temporarily held
• They are small in capacity but have an extremely fast read and write rate
• Data can be written to and read from a register much faster than from primary (Main
Memory/RAM) or secondary storage (Hard Disk)
• Computer systems use registers to hold data and instructions for processing to
increase the speed at which they can be processed – if these values were processed
straight from primary memory, processing would be much slower

Computer Science, IGCSE


Data Representation
• Using binary in computer registers (ctd)

• There are different types of registers


• Processor registers – part of the CPU and are used to process data. Suitable for situations where small
amounts of data need to be accessed quickly e.g., performing calculations

• Program Counter (PC) – holds the address of the next instruction in memory
• Accumulator (ACC) – general purpose register for calculations in the Arithmetic Logic Unit
• Memory Address Register (MAR) – contains the address of a location in memory
• Memory Data Register (MDR) – holds an instruction or data fetched from memory or being taken to memory

• Hardware registers
• Specific to different types of hardware
• Used to convey a signal e.g., to a robot to raise arm, open grip, close grip
• Each motor works via a signal – 1 for on, 0 for off
• A register is used for each motor to convey the signal

Computer Science, IGCSE


A robot arm – uses hardware registers to
control each motor

Computer Science, IGCSE


Data Representation
• Uses of Hexadecimal Numbers
• Computers do not process hexadecimal; they convert it into binary before
processing it
• Programmers work with hexadecimal as it is easier for humans to read than
binary (shorter representation than binary)
• Programs written in hexadecimal are easier to debug than those written in
binary
• It is a much shorter way of representing a byte of data (2 rather than 8
characters)

Computer Science, IGCSE


Data Representation
• Uses of Hexadecimal Numbers (continued)
• Hexadecimal is used as a notation for colour in HTML – usually 6 digits and each hex number
represents a different colour e.g., #FFAA33 is orange and #000000 is black. In #FFAA33 – the
1st 2 digits are the red component, the next 2 digits the green component and the final 2
digits the blue component (RGB). All 3 together represent the colour orange

• Standard Windows error message codes are given in hexadecimal e.g., HTTP Error 404 – File
Not Found

• Media Access Control (MAC) addresses are 12-digit hex numbers that uniquely identify each
different device in a network e.g., 00-1B-63-84-45-E6

• (IPV6 addresses (Internet Protocol) are 16 pairs of hexadecimal numbers)

• Machine code consists of simple instructions that are directly executed by the CPU.
Hexadecimal is used for machine code as each byte can be coded as 2 hexadecimal
characters (1 hex char == 4 bits)

Computer Science, IGCSE


Hexadecimal used to represent colours in
HTML

Computer Science, IGCSE


Standard Windows error message codes are
given in hexadecimal

Computer Science, IGCSE


Data Storage – text, pics, sound
• As computers can only process binary, 1’s and 0’s, all data stored on a computer is
in binary form
• Just using Binary as a User would be extremely time consuming and challenging
• Systems and Software has been developed for Users that automatically convert
text, images, video and audio into binary for the computer to store

2 Systems commonly used for characters (Text, numbers and symbols)


• ASCII – American Standard Code for Information Interchange – 8 bits/1 byte – 256 characters
(was good enough for Standard English language BUT not big enough for some other
languages)

• Unicode – 16 bits/2 bytes – 65 536 possible characters

• In ASCII and Unicode, each character is represented as a binary number

Computer Science, IGCSE


The word “Computer” in ASCII

Computer Science, IGCSE


Data Storage –pictures
Pictures
• An image, as we see it, is analogue data
• Needs to be converted to digital for a computer to process it
• Can use Scanners, Digital Cameras to do this

• Images are made up of pixels – a tiny dot on the screen


• For a Black and White image – each pixel would either be Black (1) or White (0),
however we need to know additional data e.g., the dimensions of the picture
• Metadata gives the dimensions of the image (how wide, how high - resolution of the
image)
• For a Colour image – further binary data is needed to represent the colour of each
pixel. Therefore, color images can become large files. A typical system is the RGB
color system (Red, Green, Blue)

Computer Science, IGCSE


Draw this black and white image (11 X 12)
00110001100
01001010010
10000100001
10011011001
10010101001
10010001001
10001010001
01000100010
00100000100
00010001000
00001010000
00000100000
Computer Science, IGCSE
Draw this black and white image (11 X 12)
00110001100
01001010010
10000100001
10011011001
10010101001
10010001001
10001010001
01000100010
00100000100
00010001000
00001010000
00000100000
Computer Science, IGCSE
Video - link
• https://youtu.be/ytNzrUJnfZI

Computer Science, IGCSE


Data Storage – sound
Sound
• The sound we hear is analogue. It needs to be converted to digital to be
processed by a computer
• Sound is recorded using a microphone and converted to binary by software
• Sound is recorded at set time intervals – a process called sampling
• The samples are converted into binary
• If the set timed intervals are closer together, the soundtrack will be higher in
quality – with more samples taken, the sound can be more accurately
captured
• Sample rates are measured in hertz – 1 hertz equals 1 sample per second
• Examples – a telephone communication samples a voice at 8000 hertz but a
higher quality recording, such as a CD, samples music at 44 100 hertz

Computer Science, IGCSE


Simple Sound Wave
15
- / \'

~10 I
/
/
'"'
'..
-
, I
I
I \
\

-> \
,
' '

::J J
I \ /--.
m
I \ I '\ \ J
/
'
I
''
"'O
C I \ ./
I
::I
I \ I \
0 5 l \ J
V)
I \ I
I '\ /: \ I
\ I \ I
I '-../ ' \I
I
'

0
,
I ' '-/
8 9 10 11 12
4 5 6 7
0 1 2 3
Time samples

Computer Science, IGCSE


If we record the sound value at each time
sample:
Table 1.12 I

9
1
10 \ 11
1
I 12 '
I

6 7 8
Time sample 1 2 3 4 5
8 5 8 \ 5.5 \
4 1.5 9 I

13 3.5 9 I
Sound value , 9 9

If we then play back the recording the system will use the value at each sample interval to do
this. The resu ltant wave is shown in Figure 1.15.

15 1 I \ \

/
~'-
' \
\
V
/
"' 1

~10
-
:l
I
J
" /
/\
\. I
J ---..........__
/ '"'-.
-0
I
I "
'\.
:/
/ \
\.
I '" " " , /

' ------- I
C
:l
0 5 I '\ \. I
(/)
I \., I
I
I

0 - - a I I
l I

8 9 10 11 '
12.
Time samoles

Computer Science, IGCSE


Comparison of Quality between Analogue
Wave (blue) and Digital Wave (red)
Figure 1.15 Sound wave created by playing back a recorded sound

15 I
l I \ \
I\.
1
\
I \ \

"' LO I/
/ / .'\." '
/ / " \.
'\.\
' \
\
\
' \
\
->
(I)
:, V "\
\ / /·
------ \ "-. - \ \

"'
n:, J .

/ / l["....._
I \ I I \\ I
""C
II \ II '\ I I /
C:
:::,
II \. II I \ V \ "'\\
5
"'
0 \
V,
II f I \ J \
II / \ / j \ \ \
I '-......../ \ I I \ I \ \
I \....._,I V \ \
I I \ \
0 I I I 1

10 11 11
I I

0 1 2 3 4 5 6 7 8 9
Time samples
Computer Science, IGCSE
Video - link
• https://youtu.be/zt_JvGbQUbE

Computer Science, IGCSE


Data Compression
• Data compression happens when the the structure of a file is manipulated
in such a way that the data in a file becomes smaller in size
• This means that less storage space is required to store the file and the file
will be transmitted faster from 1 device to another
• Data compression is done using compression algorithms that manipulate
the data
• These algorithms normally manipulate the data so that repeating data is
removed, either on a temporary or permanent basis – depending on the
method used
• 2 main methods for compressing data – lossy and lossless

Computer Science, IGCSE


Data Compression
• Lossy compression e.g., MP3, MP4, JPEG
• Derived from the word “loss”
• This method ‘loses’ data
• Data deemed to be redundant or unnecessary is removed permanently in the
compression process – i.e., lost, so that the file becomes smaller
• Mostly used for multimedia e.g., audio, video and image files; done when
streaming these files, as a file can be streamed more effectively if it is smaller
in size
• If used on a music file – removes all background noise and noises that may
not be heard by a human ear – will not sound the same but will be a very
close representation of the original music file

Computer Science, IGCSE


Data Compression
• Lossless compression
• No data is lost in the process
• File can be reconstructed exactly as it was
• Used when it is essential that no data is lost or discarded during the compression
process
• Many lossless compression algorithms – most work using some form of shorthand to
store the data so they can be reconstructed when the file is opened
• If lossless compression is used on a music file it will not lose any of the data from the
file. It will look for repeating patterns in the music, store the pattern once along with
how many times it is repeated and where. When the music track is played, the full
track, exactly as it was recorded, can be reconstructed and listened to
• Lossless compression can also be used when storing text files

Computer Science, IGCSE


Lossless compression example
WHEN IT IS SNOWING HEAVILY LOOK OUTSIDE.
LOOK OUTSIDE IT IS SNOWING HEAVILY.
46 vs 62 bytes and no data lost (a 26% reduction in storage) – file can be reconstructed exactly as it was
(ignore full stops and spaces)

Word Position in the Message


WHEN 1
IT 2, 10
IS 3, 11
SNOWING 4, 12
HEAVILY 5, 13
LOOK 6, 8
OUTSIDE 7, 9
Total bytes - 33 Total bytes - 13

Read the message by following the Position in the Message


Computer Science,and
IGCSEusing the related Word.
Lossless Compression Example for you to
compress
Ask not what your friend can do for you.
Ask what you can do for your friend.

Computer Science, IGCSE


Lossless compression example
Ask not what your friend can do for you.
Ask what you can do for your friend.
48 vs 59 bytes and no data lost (19% reduction) – file can be reconstructed exactly as it was
(ignore full stops and spaces)

Word Position in the Message


Ask 1, 10
not 2
what 3, 11
your 4, 16
friend 5, 17
can 6, 13
do 7, 14
for 8, 15
you 9, 12
Total bytes - 31 Total
Computer Science, bytes
IGCSE - 17
Video - link
• https://youtu.be/0ohspbFwoks

Computer Science, IGCSE


Image Files
• Uncompressed image files can potentially be huge
• This makes uploading, downloading or emailing them very difficult and time
consuming. Many email systems limit the size of the file that can be attached –
this means that most uncompressed, high-quality images cannot be attached to
an email without being compressed
• Both the lossy and lossless compression methods reduce the size of an image by
looking for repeating colour patterns within the image e.g., the main background
colour can be stored as a single data value with further data that records the
pattern
• Lossy compression will reduce the file further by removing detail from the image
that should go unnoticed and will not affect the quality too much – the problem
with this type of compression is that each time the image is saved, a little bit of
detail will be removed e.g., JPEG So a small loss of quality occurs every time the
picture is saved

Computer Science, IGCSE


File formats
• A file format is the method that we chose to store different data on a
computer
• Different file formats encode the data in different ways
• It is important for software to recognize the file format used to save
the data in order to access it
• There are many different types of file format - some are specific to
software, and some are more generic or standard
• Certain file formats are designed for a particular type of data e.g.,
text, images or multimedia

Computer Science, IGCSE


File Formats
• These are the most common file extensions:
File Type File Extension Use
Text .doc MS Word
.rtf Rich Text Format file
pdf Portable Document
Format
Data .csv Comma Separated Values
file
.xls MS Excel Spreadsheet
.mdb MS Access DB

Computer Science, IGCSE


File Formats
File Type File Extension Use
Audio .mp3 MP3 Audio file
.mid MIDI file
.wav Wave Audio file
Video .mp4 MPEG-4 video file
.flv Flash video file
.wmv Windows Media Video file
Image .bmp Bitmap file
.gif Graphical Interchange
Format file
.jpg JPEG Photo
.png Portable Network Graphic

Computer Science, IGCSE


Multimedia Standards (MIDI, JPEG, MP3,
MP4)
• MIDI – Musical Instrument Digital Interface uses a series of protocols and interfaces that
allow lots of different types of musical instruments to connect and communicate. Allows
1 computer or instrument to control other instruments. The controlling device instructs
the others on which notes to play and when, while specifying the pitch, duration and
velocity of each note. MIDI files are not a musical recording but a series of instructions
for an instrument to carry out
• JPEG – Joint Photographic Experts Group – standard format for lossy compression of
images. Can reduce files down to 5% of original size
• MP3 – standard format for lossy compression of audio files
• MP4 – standard format for lossy compression of video files. Can also be used on audio
and images
• MP3 and MP4 have developed from the original file format MPEG (Multi Pictures Expert
Group). This is a lossy compression method for video files
• JPEGs, MP3s and MP4s are used in a wide variety of devices such as computers, digital
cameras, DVD/Blu-ray players and smartphones to store content

Computer Science, IGCSE


Summary
• As humans we process analogue data, but computers process digital data
• Computers use a binary number system – consists of 1’s and 0’s to
represent data and instructions
• Computer storage systems are measured in multiples of bytes
• A register is a small piece of memory where values can be held. Computers
use them to hold data and instructions for processing
• Computers do not process hexadecimal notation – converted to binary
first. Programmers work with hex as it is shorter and easier to read than
binary
• Computers convert text, images and sound into binary to process and store
• Data compression reduces the size of a file – lossy and lossless
• File formats are the method chosen to store data on a computer
Computer Science, IGCSE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy