Chap1-DataRepresentation-Notes
Chap1-DataRepresentation-Notes
CONTENTS
1.1 Number
Systems
Computers &
Binary Number
Systems
Converting Between Binary & Denary
Converting Between Hexadecimal & Binary
Converting Between Hexadecimal & Denary
Hexadecimal
Binary
Addition
Binary Shifts
Two's Complement
1.2 Text, Sound and
Images Character Sets
Representing Sound
Representing Images
1.3 Data Storage and
Compression Data Storage
Compression
1.1 Number Systems YOUR NOTES
Logic Gates
Logic gates are electronic devices that perform logical operations on binary data
The most common types of logic gates are AND, OR, and NOT gates, which can be
combined to perform more complex operations
AND and OR gates both have 2 inputs (A and B) whereas a NOT gate only has 1
input (A) X is the output from the logic gate
Logic gates are used to process binary data by applying Boolean logic to the input
values and producing a binary output
Registers are temporary storage areas in a computer's CPU (central processing unit)
that hold binary data during processing
Registers are used to store data that needs to be accessed quickly, such as variables
in a program or data being manipulated by logic gates
The size of a register determines the maximum amount of binary data that can be
stored in it at one time
Number Systems YOUR NOTES
Page 3 of 20
We know this as (1 x 8) + (1 x 4) + (0 x 2) + 0 x 1) =12 YOUR NOTES
Exam Tip
You need to be able to make conversions in both directions, e.g. denary to
binary or binary to denary. Make sure you write the table the correct way round
(with 1 in the right hand column) & use the correct number of bits in your
answer (the question should tell you but use multiples of 4 bits if you’re not
sure)
Page 4 of 20
Converting Between Binary & Denary YOUR NOTES
128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 1
Starting from the leftmost column, write a 1 if the corresponding power of 2 is less
than or equal to the number you’re converting, 171 in this example, otherwise write a
0.
128 64 32 16 8 4 2 1
1 0 1 0 1 0 1 1
Check your working by adding together all column headings with a 1 underneath
(128+32+8+2+1=171)
Read the binary digits from left to right to get the binary equivalent of
171. 10101011
128 64 32 16 8 4 2 1
Starting from the leftmost column, write the binary digit in the column if it is a 1 write
1, and write 0 if it is a 0.
128 64 32 16 8 4 2 1
0 1 1 0 0 1 1 0
Page 5 of 20
Converting Between Hexadecimal & Binary YOUR NOTES
0 1 1 0 1 1 1 0
8 4 2 1 8 4 2 1
1 0 1 0 0 0 1 0
Page 6 of 20
Converting Between Hexadecimal & Denary YOUR NOTES
161 160
16 1
If the hex digit is a letter, convert it to its denary equivalent (Using the following table
to help you):
Hexadecimal Decimal
A 10
B 11
C 12
D 13
E 14
F 15
The hexadecimal value of the leftmost digit is E, which has a decimal value of 14. The
hexadecimal value of the rightmost digit is 5, which has a decimal value of 5.
Multiply each decimal value by its corresponding place value, and sum the products:
16a 1
Page 7 of 20
E 5 YOUR NOTES
Exam Tip
When doing conversions don’t remove any 0s on the right hand side of your
answer as this will cost you marks. E.g. B0 isn’t the same as B, just like 30 isn’t
the same as 3.
Page 8 of 20
Hexadecimal YOUR NOTES
Hexadecimal
Hexadecimal numbers are often used as a beneficial method of data
representation in computer science
It takes fewer digits to represent a given value in hexadecimal than in
binary One hexadecimal digit can represent four bits of binary data
It is beneficial to use hexadecimal over binary because:
The more bits there are in a binary number, the harder it is to read
Numbers with more bits are more prone to errors when being copied
Worked Example
The following binary number has 24 bits: 101110110011101011101010. Write
the number in hexadecimal and explain why it is better to write the number in
hexadecimal rather than in binary.
This number can be represented with only 6 digits in hexadecimal: B [1
mark] B [1 mark] 3 [1 mark] A [1 mark] D [1 mark] 2 [1 mark] .
This number is:
Much shorter and a more e cient way of representing numbers [1
mark] Easier to spot any errors in [1 mark]
Exam Tip
When a question is asked which asks you to name a certain number of uses
of hexadecimal, ensure you write the number asked for and no more. E.g. name
3 uses of hexadecimal - if you write more than 3, the last ones will be
ignored by the examiner, even if they’re correct
Page 10 of 20
Binary Addition YOUR NOTES
Binary Addition
Adding binary numbers follows a similar process to adding denary numbers
Step 2:
Begin by adding the LSBs together. If the sum is less than or equal to 1, write it down
in the sum column. If the sum is 2 or greater, write the remainder of the sum (i.e., the
sum minus 2) in the sum column and carry over the quotient (i.e., 1) to the next
column
Step 3:
Repeat this process for the next column to the left, adding the two bits and any
carryover from the previous column. Again, if the sum is less than or equal to 1, write
it down in the sum column; if the sum is 2 or greater, write the remainder of the sum in
the sum column and carry over the quotient to the next column.
Step 4:
Continue this process for each subsequent column until you have added all the bits.
Step 5:
If the sum of the last two bits produces a carryover, add an additional bit to the left of
the sum to represent the carryover.
Step 6:
Check the sum to make sure it fits within 8 bits. If it doesn't, you will need to use more
bits to represent the sum.
Page 11 of 20
Adding binary walkthrough: YOUR NOTES
In this example, we start by adding the two LSBs: 0 + 0 = 0, which we write down in
the sum column. We then move to the next column to the left and add the two bits
and the carryover from the previous column: 1 + 1 + 0 = 10. We write down the
remainder of the sum (i.e., 0) in the sum column and carry over the quotient (i.e., 1) to the
next column. We repeat this process for the next two columns, and end up with the sum
101110000.
Overflow
An overflow error occurs when the result of a binary addition exceeds the maximum
value that can be represented. In the case of 8−bits, the maximum value is 255
Overflow occurs when the addition of two numbers results in a carry bit that
cannot be accommodated
To avoid overflow errors, it's important to check the result of binary addition to ensure
that it doesn't exceed the maximum value that can be represented
Overflow errors can also occur in other operations besides addition, such as
multiplication or division
Exam Tip
You can convert your binary numbers to denary, then perform the
calculation and then convert them back to check you’ve got the right answer.
Label this as checking to make sure that the examiner knows this is a check
and not part of your working out
Page 12 of 20
Binary Shifts YOUR NOTES
Binary Shifts
A binary shift is the term used for multiplying or dividing in binary
A binary shift moves all the bits in a binary number a certain number of positions to
the left or right
When performing a logical binary shift to the left, the bits shifted from the end of the
register are lost, and zeros are shifted in at the opposite end
When performing a logical binary shift to the right, the bits shifted from the beginning
of the register are lost, and zeros are shifted in at the opposite end
When performing a logical binary shift, the positive binary integer is multiplied or
divided according to the shift performed. A shift to the left is equivalent to
multiplication by a power of 2, while a shift to the right is equivalent to division by
a power of 2
When performing a logical binary shift, the most significant bit(s) or least significant
bit(s) are lost, depending on the direction of the shift
Exam Tip
Make sure you’ve got the same number of bits in your answer as there were
in the question. Check your answer by converting the binary number to
denary, working out your answer and converting it back again. Make sure to
label this checking so the examiner knows it isn’t part of your working out
Page 13 of 20
Two's Complement YOUR NOTES
Two's Complement
Two's complement is a method of representing signed integers in binary form, where
the leftmost bit represents the sign (0 for positive and 1 for negative)
To convert a positive number to a two's complement 8−bit integer, first represent
the number in binary form with leading zeros until it is 8 bits long. If the number is
positive, the leftmost bit should be 0
To convert a negative number to a two's complement 8−bit integer, first invert all the
bits in the binary representation of the positive equivalent of the number (i.e., flip
all the 1's to 0's and all the 0's to 1's). Then, add 1 to the result to obtain the
two's complement representation
Page 14 of 20
1.2 Text, Sound and Images YOUR NOTES
Character Sets
Character Sets
Text is a collection of characters that can be represented in binary, which is the
language that computers use to process information
To represent text in binary, a computer uses a character set, which is a
collection of characters and the corresponding binary codes that
represent them One of the most commonly used character sets is the
American Standard Code for Information Interchange (ASCII), which assigns
a unique 7−bit binary code to each character, including uppercase and
lowercase letters, digits, punctuation marks, and control characters
E.g. The ASCII code for the uppercase letter 'A' is 01000001, while the code for the
character '?' is 00111111
ASCII has limitations in terms of the number of characters it can represent, and it does
not support characters from languages other than English
To address these limitations, Unicode was developed as a character encoding
standard that allows for a greater range of characters and symbols than ASCII,
including di erent languages and emojis
Unicode uses a variable-length encoding scheme that assigns a unique code to
each character, which can be represented in binary form using multiple bytes
E.g. The Unicode code for the heart symbol is U+2665, which can be represented in
binary form as 11100110 10011000 10100101
As Unicode requires more bits per character than ASCII, it can result in larger file sizes
and slower processing times when working with text-based data
Page 15 of 20
Representing Sound YOUR NOTES
Representing Sound
Sound is a type of analog signal that is captured and converted into digital form
to be processed by a computer.
To convert sound into digital form, a process called sampling is used. This involves
taking measurements of the sound wave at regular intervals and converting
these measurements into binary data
The quality of the digital sound depends on the sample rate, which is the
number of samples taken per second. A higher sample rate results in a more
accurate representation of the original sound wave, but also increases the file
size of the digital sound
E.g. A typical CD-quality digital sound has a sample rate of 44.1 kHz, which means
that 44,100 samples are taken per second
The sample resolution is another factor that a ects the quality of the digital sound.
This refers to the number of bits per sample, which determines the level of detail
and accuracy of each sample
A higher sample resolution results in a more accurate representation of the
sound wave, but also increases the file size of the digital sound
E.g. A CD-quality digital sound typically has a sample resolution of 16 bits, which
means that each sample is represented by a 16−bit binary number
It's important to choose the appropriate sample rate and resolution based on the
specific requirements of the digital sound application. E.g. A high-quality music
recording may require a higher sample rate and resolution than a voice recording for
a podcast
MIDI
Musical Instrument Digital Interface (file)
Stores a set of instructions (for how the sound should be
played) It does not store the actual sounds
Data in the file has been recorded using digital instruments
Specifies the note to be played
Specifies when each note plays and stops playing
Specifies the duration of the note
Specifies the volume of the note
Specifies the tempo
Specifies the type of instrument
Individual notes can be edited
Page 16 of 20
Representing Images YOUR NOTES
Representing Images
A bitmap image is made up of a series of pixels, which are small dots of colour
that are arranged in a grid. Each pixel can be represented by a binary code, which is
processed by a computer
The resolution of an image refers to the number of pixels in the image. A higher
resolution image has more pixels and is, therefore, sharper and more detailed but also
requires more storage space
The colour depth of an image refers to the number of bits used to represent each
colour. A higher colour depth means that more colours can be represented,
resulting in a more realistic image but also requires more storage space
E.g. an 8−bit colour depth allows for 256 di erent colours to be represented
(28=256), while a 24−bit colour depth allows for over 16 million di erent colours to
be represented
(224=16,777,216)
The file size of an image increases as the resolution and colour depth increase.
This is because more pixels and colours require more binary data to represent
them The quality of an image also increases as the resolution and colour
depth increase. However, it's important to balance the desired quality with
the practical limitations of storage space
Page 17 of 20
1.3 Data Storage and Compression YOUR NOTES
Data Storage
Data Storage
Data storage is measured in a variety of units, each representing a di erent size of
storage capacity. The smallest unit of measurement is the bit, which represents a single
binary digit (either 0 or 1)
A nibble is a group of 4 bits, while a byte is a group of 8 bits
Kibibyte (KiB), mebibyte (MiB), gibibyte (GiB), tebibyte (TiB), pebibyte (PiB),
and exbibyte (EiB) are all larger units of measurement
Specifically, 1 KiB is equal to 2^10 bytes, 1 MiB is equal to 2^20 bytes, 1 GiB is
equal to 2^30 bytes, 1 TiB is equal to 2^40 bytes, 1 PiB is equal to 2^50 bytes,
and 1 EiB is equal to 2^60 bytes
To calculate the file size of an image file:
Determine the resolution of the image in pixels (width x height)
Determine the colour depth in bits (e.g. 8 bits for 256 colours)
Multiply the number of pixels by the colour depth to get the total number of
bits Divide the total number of bits by 8 to get the file size in bytes
If necessary, convert to larger units like kibibytes, mebibytes, etc
Worked Example
Calculating image file size
walkthrough:
An image measures 100 by 80 pixels and has 128 colours (so this must use 7
bits) 100 x 80 x 7 = 56000 bits ÷ 8 = 7000 bytes ÷ 1024 = 6.84
To calculate the file size of a sound file:
kibibytes
Determine the sample rate in Hz (e.g. 44,100
Hz) Determine the sample resolution in bits (e.g.
16 bits) Determine the length of the track in
seconds
Multiply the sample rate by the sample resolution to get the number of bits per
second Multiply the number of bits per second by the length of the track to get the
total number of bits
Divide the total number of bits by 8 to get the file size in
bytes If necessary, convert to larger units like kibibytes,
mebibytes, etc
Page 18 of 20
YOUR NOTES
Worked Example
Calculating sound file size walkthrough:
A sound clip uses 48KHz sample rate, 24 bit resolution and is 30 seconds
long. 48000 x 24 = 1152000 bits per second x 30 = 34560000 bits
for the whole clip
34560000 ÷ 8 = 4320000 bytes ÷ 1024 = 4218.75 kibibytes ÷ 1024 =
4.12
mebibytes
Exam Tip
Remember to always use the units specified in the question when giving the
final answer.
Page 19 of 20
Compression YOUR NOTES
Compression
Lossless Compression:
A compression algorithm is used to reduces the file size without permanently
removing any data
Repeated patterns in the file are identified and indexed
Techniques like run-length encoding (RLE) and Hu man
encoding are used RLE replaces sequences of repeated
characters with a code that represents the character
and the number of times it is repeated
Hu man encoding replaces frequently used characters with
shorter codes and less frequently used characters with
longer codes
Lossy Compression:
Lossy compression reduces the file size by permanently
removing some data from the file
This method is often used for images and audio files where
minor details or data can be removed without significantly
impacting the quality
Techniques like downsampling, reducing resolution or
colour depth, and reducing the sample rate or resolution
are used for lossy compression
The amount of data removed depends on the level of
compression selected and can impact the quality of the
final file
Overall:
Compression is necessary to reduce the size of large files
for storage, transmission, and faster processing
The choice between lossy and lossless compression
methods depends on the type of file and its intended use
Lossy compression is generally used for media files where
minor data loss is acceptable while lossless compression is
used for text, code, and archival purposes
Page 20 of 20