Data Representation Notes-2
Data Representation Notes-2
Number System
Since computers contain millions and millions of tiny ‘switches’, which must be in the ON or OFF position, they
can be represented by the binary system. A switch in the ON position is represented by 1; a switch in the OFF
position is represented by 0.
Decimal number is a base 10 number system. Values from 0 to 9 are used to represent all values. Ex; 65, 562
Hexadecimal number is a base 16 number system. Values form 0 to 15 are used, from 10 to 15 letters A,B,C,D,E,F
are used to represent values. Ex; 2A, FD8, E04
Method 1
1|Page
The hexadecimal system
Because it is a system based on 16 different digits, the numbers 0 to 9 and the letters A to F are used to represent
each hexadecimal (hex) digit. A in hex = 10 in denary, B = 11, C = 12, D = 13, E = 14 and F = 15.
A typical example of hex is 2 1 F 3 A. Since 16 = 24 this means that FOUR binary digits are equivalent to each
hexadecimal digit. The following table summarises the link between binary, hexadecimal and denary:
Table 1.1
2|Page
4. Converting from Hexadecimal to binary
Converting from hexadecimal to binary is also very straightforward. Using the data in Table 1.1, simply take each
hexadecimal digit and write down the 4-bit code which corresponds to the digit.
Convert the hexadecimal value into binary then binary into decimal
0 1 1 1 0 0 1 0 1 1
1 12 11
1 (C) (B)
Ans: 1CB
3|Page
Four uses/Applications of the hexadecimal system:
4|Page
Activity
a) 0 0 0 1 1 1 0 1 + 0 1 1 0 0 1 1 0 b) 144 + 63
(b) Understand the concept of overflow and why it occurs in binary addition
• An overflow error will occur if the value is greater than 255 in an 8-bit register
This addition has generated a 9th bit. The 8 bits of the answer are 01001100 – this gives the denary value [64 + 8 +
4] of 76 which is incorrect because the denary value of the addition is 110 + 222 = 332
The maximum denary value of an 8-bit binary number is 255. The generation of a 9th bit is clear indication that the
sum has exceeded this value. This is known as an overflow error.
Activity:
Convert the following pairs of denary numbers to 8-bit binary numbers and then add the binary numbers.
Comment on your answers in each case:
6|Page
7|Page
Two’s complement (binary numbers)
Up until now, we have assumed all binary numbers are positive integers. To allow the possibility of representing
negative integers we make use of two’s complement. Only one minor change to the binary headings needs to be
introduced here:
A 1-value in the left-most bit indicates a negative number and a 0-value in the leftmost bit indicates a positive
number (for example, 00110011 represents 51 and 11001111 represents −49).
-128 64 32 16 8 4 2 1
0 0 1 1 0 0 1 1
denary number is 51
8|Page
-128 64 32 16 8 4 2 1
1 1 0 0 1 1 1 1
Denary number is -49
-128 + 64 + 8 + 4 + 2 + 1 = -49
Activity
Convert the following positive denary numbers into 8-bit binary numbers in the two’s complement format:
a) 39 b) 125
Convert the following binary numbers (written in two’s complement format) into positive denary numbers:
a)
-128 64 32 16 8 4 2 1
0 1 0 1 0 1 0 1
b)
-128 64 32 16 8 4 2 1
0 1 1 1 1 1 0 1
9|Page
Writing Negative denary number in two’s complement format
a) Convert the negative denary numbers -56 in two’s complement format in 8-bit register
72 is made up of 64 + 8
-128 64 32 16 8 4 2 1
1 1 0 0 1 0 0 0
b) Convert -79 into an 8 – bit binary number using two’s complement format.
49 is made up of 32 + 16 + 1
-128 64 32 16 8 4 2 1
1 0 1 1 0 0 0 1
Activity:
1. Convert the following negative denary numbers into binary numbers using the two’s complement format:
a) - 18 b) - 92
10 | P a g e
Activity:
1. Convert the following negative binary numbers [written in two’s complement format] into negative denary
numbers:
-128 64 32 16 8 4 2 1
1 1 0 0 1 1 0 1
-128 64 32 16 8 4 2 1
1 0 1 0 1 1 0 0
Increasing colour depth also increases the size of the file when storing an image.
The resolution can be varied on many cameras before taking. In the given picture below, Image ‘A’ has the highest
resolution and ‘E’ has the lowest resolution. This is because there are fewer pixels in ‘E’.
12 | P a g e
Drawback of high resolution:
Increase in pixels
Increase in file size
Takes more time to download from internet
Takes more time to transfer from device to device
Exercise question1:
One of the images has a resolution of 1000 x 1000 and a colour depth of 16 bits. Calculate the file size
of the image. Give your answer in bytes.
Exercise question2:
George is a wedding photographer. She wants to store 10 photographs on a USB flash memory drive for
a customer. Each photograph is 100 pixels wide and 50 pixels high. The photographs are 8-bit colour
photographs.
a) Calculate the total file size, in kilobytes(kB), of all the photographs. For this calculation, you may use the unit
of measurement of 1024 or 1000.
5000 / 1000 = 5 KB
13 | P a g e
A File Size 5 KB
10 x 5 = 50 KB
Exercise question3:
Jessica wants to store a large number of small thumbnail images on a USB flash memory drive. Each thumbnail
image is 16-bit colour and is 100 pixels wide and 100 pixels high.
She has 5MB of storage space available on her USB flash memory drive.
Calculate how many images she can store in the 5MB of storage space. Show all your working
Number of images,
Exercise Question4:
Number of Photographs
14 | P a g e
Representation of sound in binary
Sound is made up of sound waves. When sound is recorded, this done at set time intervals. This process is known
as sound sampling.
Sound sampling is a little piece of sound that is recorded at regular time intervals.
Sample resolution is the number of bits that are used to record each sound sample
If you recorded the sound at each time sample, you would have the following set of values:
Time sample 1 2 3 4 5 6 7 8 9 10 11 12
Sound value 9 13 9 3.5 4 9 1.5 9 8 5 8 5.5
Each sound wave is converted to binary to be processed by the computer. Each sound value is then used to
playback the sound, when the recording is played. If the recorded sound wave is played it would now look like the
figure given below
You will notice that the two sound waves look different. This is because the number of sample taken is too far
apart, so vital data is between time samples has been lost. This will result in a lack of accuracy in the sound that is
recorded. Therefore, more sound samples need to be taken each second to improve the accuracy of the recorded
sound. The number of samples taken in a second is called the sample rate. Sample rates are measured in hertz. 1
hertz is equal to 1 sample per second. A common sample rate is 44.1khz(kilohertz), this would require 44100
sample to be taken each second. That is a lot of data! If the sample rate is increased, the amount of data required
for the recording is increased. This increases the size of the file that stores the sound.
Further data is required to represent sound, and this is the sample resolution. Sample resolution is the number of
bits that are used to record each sound sample
15 | P a g e
A common sample resolution is 16 bit. The higher the sample resolution the greater the variations in amplitude
that can be stored for each sample. This means the sound can be recorded more accurately.
This will also increase the amount of data and file size to be stored for each sample.
Exercise 1:
An audio CD has a sample rate of 44100 Hz and a sample resolution of 16 bits. Calculate the file size for 12
seconds recording
Size of file =
Exercise 2:
Audio is being sampled at the rate of 44.1kHz using 8 bits. Two channels are being used for stereo sound.
Calculate:
16 | P a g e
Exercise 3:
The typical song stored on a music CD is 1 minute. Assuming each song is sampled at 44.1kHz(44100 samples per
second) and 16 bits are used per sample. Each song utilises two channels.
File Compression
Compression is a method that uses an algorithm to reduce the size of a file
Lossy Compression
A compression method that reduces the size of a file by permanently removing data
Lossless Compression
A compression method that reduces the size of a file by temporarily altering the data and the data can be
retrieved back
17 | P a g e
How Image file is compressed
● Applied lossy compression algorithm
● Removes colours human eyes can’t distinguish, thus reducing the colour depth
● Uses perceptual music shaping, means removes sounds human ears can’t hear very well
● Repeated word sections (e.g, “OU”, “THE”) can be replaced by a numerical value
● Index and numerical values are saved in a table of dictionary to recover original file later
● Convert to PDF
● RLE(Run Length Encoding) can be used for lossless compression. It reduces the size of a string of adjacent,
identical data
18 | P a g e