Ch1 DataRepresentation
Ch1 DataRepresentation
Chapter 1
This chapter considers the three main Number systems and how they are used to measure
computers memory and storage
Ch1: Data Representation
0 1
1.1.2 Binary, Denary and Hexadecimal
Systems
Binary Number?
27 26 25 24 23 22 21 20
Let’s convert some
128 64 32 16 8 4 2 1 numbers
1 0 0 1 1 0 1 0
Converting Binary Example
numbers to Denary
11101110
2+4+8+32+64 27 26 25 24 23 22 21 20
+128= 238 128 64 32 16 8 4 2 1
1 1 1 0 1 1 1 0
Converting Binary
numbers to Denary a. 00110011
b. 01 111 1 11
c. 10011001
d. 01110100
Converting Denary
numbers to Binary Example- Method 1
142-128=14 142
14-8=6 27 26 25 24 23 22 21 20
6-4=2 128 64 32 16 8 4 2 1
2-2=0 1 0 0 0 1 1 1 0
http://games.penjee.com/binar
y-numbers-game/
Play a game?
Let’s Practice a little
http://www.mathsisfun.com/binary-decimal-hexadecimal-converter.html
1.1.2 Binary, Denary and Hexadecimal Systems
Hexadecimal System
110111100001
Split it into groups of 4 bits
B E 1
Hexadecimal
16 conversions
From hexadecimal to denary and from denary to hexadecimal
1.1.3 Use of Hexadecimal System
Binary
1101001010101111
Hexadecimal D2AF
The hex number
is far easier for humans to
remember, copy and work
with
1.1.3 Uses of hexadecimal system
404 NOT
FOUND
IPv6
HTML color codes
a 128-bit number broken down into 16-bit HTML is often used to represent colours of text on the
chunks computer screen
Error codes
p s
u m
y d
o r
e m
M
MAC addresses
NN-NN-NN-DD-DD-DD or NN:NN:NN:DD:DD:DD
IPv6 uses a colon (:) rather than a decimal point (.) as used in IPv4
HTML Color Codes
# R G B
# FF 00 00 red
# 00 FF 00 green
# 00 00 FF blue
1.1.4
Addition of binary numbers
Addition oftwo 8-bit positive binary numbers
Simalarity to denary addition
Denary Binary
11 1010
137 11100
194
10110
331
Perform the above additions
Overflow
The generation of a
01101110 number or other data
Overflow
Error 11011110 item that is too large for
the assigned location or
101001100 memory space
1.1.5
Logical binary shifts
Computerscan carry logical shifts which means moving the binary numbers to the
left or right
Logical Shifts
Multiplication (shift to the Division (shift to the right)
left)
Equivalent to dividing
Equivalent to the binary number by
multiplying the binary 2
number by 2
Multiplication
Logical Shifts
128 64 32 16 8 4 2 1
1 0 1 0
1 0 1 0 0
Logical Shifts
128 64 32 16 8 4 2 1
1 0 1 1 0 0
1 0 1 1 0
0 0 0 1 0 1 0 1
Multiply by 2
0 0 1 0 1 0 1 0
Multiply by 4
0 1 0 1 0 1 0 0
Multiply by 8
1 0 1 0 1 0 0 0
Multiply by 16
0 1 0 1 0 0 0 0
Logical Shifts
1.1.6
Two’s Complement
So farwe have looked at how to represent positive numbers in binary. For negative
numbers a system called Two’s Complement is used.
1.1.6 Two’s complement
What is the binary number for the denary number 15?
0000 1111
How do you think -15 is represented?
1.1.6 Two’s complement
15 0000 1111
-15 1111 0001
1.1.6 Two’s complement
The two’s complement is calculated as follows:
128 64 32 16 8 4 2 1 Calculating -15
1011 0001
1.1.6 Two’s complement
’ s e!
et
L ac t i c 1011 0001
p r 128 64 32 16 8 4 2 1
1 0 1 1 0 0 0 1
0 1 0 0 1 1 1 1 Add 1
Starter
• A computers memory and storage only hold binary 1s and 0s
• How might it be possible to store letters with only binary?
ASCII and Unicode
Unit 2 Data representation
0 1 0 0 1 1 0 1
ASCII and Unicode
Unit 2 Data representation
Representing characters
in binary
• Every character on the keyboard is represented by a binary value
• Uppercase letters (capitals) have different values from lowercase characters
• Punctuation symbols have their own character code
Characters in binary
• A keyboard needs to contain
• 26 lowercase letters
• 26 uppercase letters
• 10 numbers
• (around) 36 other characters
Character sets
• A character set is a set of letters, symbols and digits that can be represented by
a computer
• There are two major character sets in use today
• ASCII
• Unicode
ASCII and Unicode
Unit 2 Data representation
• Originally only seven bits were used, but now an eighth bit is used allowing for many
more characters such as ©, ® etc.
• 8-bit ASCII is called Extended ASCII
• How many different characters can be encoded using
7 bits, 8 bits or 16 bits?
ASCII and Unicode
Unit 2 Data representation
Character codes
• A 7-bit character code (like ASCII) has
128 different characters that can be encoded
• An 8-bit character code (like extended ASCII) has
256 different characters that can be encoded
• A 16-bit character code has 65 536 different characters that can be encoded
ASCII and Unicode
Unit 2 Data representation
Unicode
• In Japanese, konnichiwa is used as a greeting meaning ‘good day’
• In Unicode this is written as three 16-bit characters
Unicode
• ‘good day’ requires 8 bytes to store
• 今日は requires 6 bytes to store
(3 characters × 2 bytes)
• Unicode is also used to
store emoji
• ‘e’ is Japanese for picture
• ‘moji’ is Japanese for
character or alphabet
Plenary
• Work in a pair to answer the following questions
• How many bits are in extended ASCII?
• How many characters does this allow for?
• How many bytes are in Unicode?
• If ‘f’ has the ASCII code 102, what is the ASCII code for ‘g’?
• How many bytes are needed to store “Hello everyone.”?
ASCII and Unicode
Unit 2 Data representation
Plenary
• How many bits are in extended ASCII? 8 bits
• How many characters does this allow for? 256
• How many bytes are in Unicode?
16-bit has 2 bytes, 32-bit has 4 bytes
• If ‘f’ has the ASCII code 102, what is the ASCII code for ‘g’? 103
• How many bytes are needed to store “Hello everyone.”?
15 letters (remember space and the full stop)
1.2.2 Representation of Sound
Analogue sound signals are continuous
1 0 1 0 1 0 1 0 1 0 1 0
• Each sample of the sound wave is then encoded as series of binary digits.
1.2.2 Representation of Sound
Sample Resolution (bit depth)
Is the number of bits per sample
What is the
sample rate in
hertz of the this
sample?
1.2.2 Representation of Sound
Sample Rate
• The frequency or sample rate per second affects the level of detail in the digital representation
• The greater the frequency, the greater the accuracy, and file size
72 bits / 8 = 9 bytes
1.2.2 Representation of Sound
In pairs, take turns to test each other on the
following questions:
• The sample rate is measured in what unit?
• The number of bits available to store each sample is known as what?
• What is the formula for calculating the size of an uncompressed music
file?
• Track1.wav uses a sample rate of 20 kHz, Track2.wav uses a sample
rate of 10 kHz. Which file is the higher quality? Which is the larger file
size?
ANSWERS
01 = 10 =
00 = 11 =
1.2.3 Representation of Bitmap images
Colour depth (bit depth)
• Each pixel can represent a finite number of colours
• A pixel is attributed a number of n bits
• The number of combinations (2n) dictates the bit depth and therefore the number of colours that can be
represented
• A higher colour depth gives a greater range of colour and a better quality of image
20 pixels
file size?
8 colours
1.2.3 Representation of Bitmap images
Effects of varying colour depth
Changing the colour depth of an image will affect the number of colours it can display, as shown below:
0111,
0011,
0101,
1000
1.2.3 Representation of Bitmap images
Converting a bit pattern into a monochrome image
Convert the following bit pattern into an 8 × 8 icon:
00000011
00000101
00001010
01010100
01101000
00110000
01011000
10000000
1.2.3 Representation of Bitmap images
Converting a bit pattern into a monochrome image
Convert the following bit pattern into an 8 × 8 icon:
00000011
00000101
00001010
01010100
01101000
00110000
01011000
10000000
1.2.3 Representation of Bitmap images
Calculating file sizes of images
=8x8×8
= 512 bits
= 512/8
= 64 bytes
1.3
Data Storage and File Compressions
Measurement of data storage
Bits and bytes
1.3.1
Many units are used for data storage in computers
1 bit = a single 0 or 1
1 byte = 8 bits = 1 character of text
1 nibble = 4 bits or half a byte
1 KiB (kibibyte) = 1024 bytes
1 MiB (mebibyte) = 1024 KiB
1 GiB (gibibyte) = 1024 MiB
1 TiB (tebibyte) = 1024 GiB
1 PiB (pebibyte) = 1024 TiB
1 EiB (exbibyte) = 1024 PiB
Measurement of data storage
Kibibyte or kilobyte?
1.3.1
All other unit prefixes work the same way
1 megabyte is 1000,000 bytes
1 kilobyte is 1000 bytes 1 mebibyte is 1,048,576 bytes (1024 x
1 kibibyte is 1024 bytes 1024)
Measurement of data storage
Base 10 system of units
1.3.1
Measurement of data storage
Base 2 system of units (IEC)
1.3.1
Units
One suggestion
Kites – kibi
Make - mebi
Great – gibi
Toy – tebi
Planes – pebi
for the
Elderly - exbi
Calculation of file sizes
Example 1:
1.3.2
A photograph is 1024x 1080 pixels and uses a colour depth of 32 bits. How many photographs
of this size would fit onto a memory stick of 64GiB?
Calculation of file sizes
Example 2:
1.3.2
A camera detector has an array of 2048 x2048 pixels and uses a colour depth of 16. find the
size of an image take by this camera in MiB.
Calculation of file sizes
Example 3:
1.3.2
An audio CD has a sample rate of 44100 and a sample resolution of 16 bits. The music being
sampled uses two channels to allow for stereo recording. Calculate the file size for a 60-minute
recording.
Calculation of file sizes 1.3.2
Calculation of file sizes 1.3.2
Data Compression 1.3.3
Compression techniques
Permanently loses some data will not lose any of the original data
Ex: JPG, GIF, MP3,MP4 Ex: PNG, TIFF
Data Compression
Lossless Compression
1.3.3
Run-length-Encoding (RLE):
For example: if a run of notes for a sound file looked like this:
This way, none of the data is lost but the file is compressed by the software finding efficient savings of data where
possible
Data Compression
Lossless Compression
1.3.3
Run-length-Encoding (RLE)
This icon could be represented in an uncompressed format where 1 = white and black = 0 as:
11110 11110 00000 00000 00000
4 w 1 b 4 w 16 b
4 1 1 0 4 1 16 0
Data Compression
Lossless Compression
1.3.3
Run-length-Encoding (RLE)
Data Compression
Lossless Compression
1.3.3
Run-length-Encoding (RLE)
Now you know what
happens when you
click a key in your
keyboard!