Uploaded by Talat Jahangir

Number Systems Worksheet: Binary, Decimal, Hexadecimal Conversions

advertisement
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
NUMBER SYSTEMS
Number System
Number systems are the technique to represent numbers in the computer system architecture,
every value that you are saving or getting into/from computer memory has a defined number
system. Computer architecture supports following number systems.
1. Denary/Decimal Number System
2. Binary Number System
3. Octal Number System (Not included in our Syllabus)
4. Hexadecimal Number system
Number system is based on some characters called digits. The number of digits is known as
base or radix of the number system.
Base in number system:
Base is used to define total number of unique digits/Symbols in a specific number system
and is also used to represent/identify a specific number system
Note Important Tip: (Always specify the base with number system)
Denary Numbers: also known as decimal numbers, they have a base-10, and
are written using the symbols 0,1,2,3,4,5,6,7,8,9.
10²
10¹
10⁰
100
10
1
Binary Numbers: are base-2, and are written using either of the symbols
and 1. A binary digit is referred to as a bit.
2¹⁰
2⁹
1024 512
2⁸
2⁷
2⁶
2⁵
2⁴
2³
2²
2¹
2⁰
256
128
64
32
16
8
4
2
1
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 1
0
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Hexadecimal Numbers: are base-16, and are written using the symbols 0, 1,
2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.
16³
16²
16¹
16⁰
4096
256
16
1
Bit : A Single Binary digit . It can be 0 or 1.
Byte: a group of 8 bits treated as a single unit
Nibble: a group of 4 bits.
(1 hexadecimal digit = 4 bits = 1 nibble)
Number System
DIGITS
Base
BINARY
0,1
2
Denary/DECIMAL
0,1,2,3,4,5,6,7,8,9
10
HEXADECIMAL
0,1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 2
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
PREFIXES :
DECIMAL PREFIX
SYMBOL
VALUE
kilo
k
10³
Mega
M
10⁶
Giga
G
10⁹
Tera
T
10¹²
BINARY PREFIX
SYMBOL
VALUE
kibi
ki
2¹⁰
Mebi
Mi
2²⁰
Gibi
Gi
2³⁰
Tebi
Ti
2⁴⁰
▼ Table 1.4 Memory size using denary values
Memory size using Binary Number System:
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 3
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
In computing, a binary prefix is a set of letters that precede a unit of digital quantity (bit and byte)
to indicate multiplication by a power of two //
A binary prefix is a unit prefix for multiples of units in data processing, data transmission, and
digital information,
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 4
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Hexadecimal Numbers:
 These are base-16 numbers where each hexadecimal digit is represented by
one of the following symbols: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F.
 The symbols A through to F represent the denary values 10 to 15.
 Each Hexadecimal number is represented in a nibble (group of four bits.). This
means that each byte of binary code can be written as two hexadecimal digits

The value of a number is defined by place values. For example, see Table 1.03
for the hexadecimal number 2A6.
Adding up the values in the bottom row shows that the equivalent denary number is
678.
Uses of Hexadecimal Numbers:

Used to Display machine code/programs/memory dump • e.g. 5F 3A 09 F1

Display (MAC) addresses • e.g. 23-45-67-89-AB-CD

Display ASCII/Unicode values • e.g. %41 for A

Display error codes • e.g. error #C04 door open

Assembly Language

Used to represent IP address (IPV6)
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 5
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Denary/Decimal to Binary
1.
(16)10
2.
(43)10
3.
(39)10
4.
(27)10
5.
(11)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 6
Computer Science (9618)
6.
(32)10
7.
(8)10
8.
(14)10
9.
(45)10
Topical (Chap 1: Number System)
Paper1
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 7
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
10. (5)10
Answers:
1. (10000)2
2. (101011)2
3. (100111)2
4. (11011)2
5. (1011)2
6. (100000)2
7. (1000)2
8. (1110)2
9. (101101)2
10. (101)2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 8
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Binary to Denary/Decimal
1.
(10000)2
2.
(101011)2
3.
(100111)2
4.
(11011)2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 9
Computer Science (9618)
5.
(1011)2
6.
(100000)2
7.
(1000)2
8.
(1110)2
Topical (Chap 1: Number System)
Paper1
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 10
Computer Science (9618)
9.
Topical (Chap 1: Number System)
Paper1
(101101)2
10. (101)2
Answers:
1.
(16)10
2.
(43)10
3.
(39)10
4.
(27)10
5.
(11)10
6.
(32)10
7.
(8)10
8.
(14)10
9.
(45)10
10. (5)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 11
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Binary to Hexadecimal
1.
(111011)2
2.
(11000111) 2
3.
(10010010) 2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 12
Computer Science (9618)
4.
Topical (Chap 1: Number System)
Paper1
(10111101) 2
5. (1001110) 2
6. (11010110) 2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 13
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
7. (11111111) 2
8. (110100101) 2
9. (100010000) 2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 14
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
10. (11000) 2
Marking Scheme:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
(3B)16
(C7)16
(92)16
(BD)16
(4E)16
(D6)16
(FF)16
(1A5)16
(110)16
(18)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 15
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Hexadecimal to Binary
1.
(3B)16
2.
(C7)16
3.
(92)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 16
Computer Science (9618)
4.
(BD)16
5.
(4E)16
6.
(D6)16
Topical (Chap 1: Number System)
Paper1
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 17
Computer Science (9618)
7.
(FF)16
8.
(1A5)16
9.
(110)16
Topical (Chap 1: Number System)
Paper1
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 18
Computer Science (9618)
10.
Topical (Chap 1: Number System)
Paper1
(18)16
Marking Scheme:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
(00111011)2
(11000111) 2
(10010010) 2
(10111101) 2
(01001110) 2
(11010110) 2
(11111111) 2
(000110100101) 2
(000100010000) 2
(00011000) 2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 19
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Denary/Decimal to Hexadecimal worksheet
1. (19)10
2. (652)10
3. (261)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 20
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
4. (54)10
5. (78)10
6. ( 943)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 21
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
7. (186)10
8. ( 85)10
9. ( 422)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 22
Computer Science (9618)
10.
Topical (Chap 1: Number System)
Paper1
(317)10
Marking Scheme:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
(13)16
(28C)16
(105)16
(36)16
(4E)16
(3AF)16
(BA)16
(55)16
(1A6)16
(13D)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 23
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Denary/Decimal to Hexadecimal worksheet
1. (13)16
2. (28C)16
3. (105)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 24
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
4. (36)16
5. (4E)16
6. (3AF)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 25
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
7. (BA)16
8. (55)16
9. (1A6)16
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 26
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
10. (13D)16
Marking Scheme:
1. (19)10
2. (652)10
3. (261)10
4. (54)10
5. (78)10
6. ( 943)10
7. (186)10
8. ( 85)10
9. ( 422)10
10. (317)10
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 27
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Two’s complement (binary numbers)
To allow the possibility of representing negative integers we make use of two’s
complement. In this section we will again assume 8-bit registers are being used.
In two’s complement to a binary number that the left-most bit always determines the
sign of the binary number.
.
0 for Positive
1 for Negative
Largest Positive Value
Smallest Positive Value
Smallest Negative Value
Largest Negative Value
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 28
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Addition of Binary Numbers:
This section 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:
Overflow:
A condition when the result of the calculation is too large to fit into the number of bits
defined for storage.
Example answer:
⇒ An overflow has occurred as the expected answer, x, is greater than the maximum of 255
which can be stored in 8 bits.
⇒ An overflow has occurred as the expected answer is outside the range of a positive integer
and
is
currently
being
shown
as
-x.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 29
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Add the following Binary Numbers :
10010
11000
1011101
1000000
0010011
1111101
10011001
00100111
11000011
00101111
1001100
1100101
Subtraction:
●
●
●
●
0−0=0
0 − 1 = 1 after a borrow
1−0=1
1−1=0
Subtraction using Two’s complement 8 bit binary number
1.
20 + (-19)
Note that the above has a numeric overflow in the MSB which we ignore completely.
Therefore answer is (00000001)2
2.
67 + (- 34)
Note that the above has a numeric overflow in the MSB which we ignore completely.
Therefore answer is (00100001)2
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 30
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
BINARY CODED DECIMAL (BCD)
● They are not used in calculations
● Each digit is treated as a single digit/entity
● Range [0-9]
● 1 BCD digit = 4 binary bits
● If digit >9 or digit <0, then digit = invalid
Digits are coded as the binary values from 0000 to 1001. The remaining codes 1010 to 1111
do not have any meaning.
Two options for BCD;
 the first is to store one BCD code in one byte, leaving four bits unused.
 The other option is packed BCD where two 4-bit codes are stored in one byte.
Thus, for example, the denary digits 8503 could be represented by either of the codes shown
in Figure 1.01.
Number of applications where BCD can be used.
 where denary digits are to be displayed, for instance on the screen of a calculator or in a
digital time display
Text, sound and images:
Character sets:
 A set of symbols that is used/recognized/supported by computer system.
 Each character is assigned a unique code called “character code”.
 When you press a key on a keyboard, a number is generated that represents the symbol for
that key. This is called a character code. A complete collection of characters is a character
set.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 31
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Common Character set
 ASCII code
. Unicode
1. ASCII code

The ASCII code system (American Standard Code for Information Interchange) was
set up in 1963 for use in communication systems and computer systems. A newer version
of the code was published in 1986.
 The standard ASCII code character set consists of 7-bit codes means it has 128 different
codes to represent characters. (0 to 127 in denary or 00 to 7F in hexadecimal
 It is a 7 bit code (2⁷ = 128 codes) stored in 8 bits.
 Only has English characters.
 It represent the letters, numbers and characters found on a standard keyboard, together with
32 control codes (that use codes 0 to 31 (denary) or 00 to 19 (hexadecimal)).
 Each character is represented by a unique ASCII Code. E.g
Character
ASCII Code
A
65
a
97
0
48
Note: sixth bit changes from 1 to 0 when comparing the lowercase and uppercase
of a character.
Extended ASCII
 It uses 8-bit codes (0 to 255 in denary or 0 to FF in hexadecimal).
 This gives 256 different codes to allow for characters in non-English alphabets and for
some graphical characters to be included
 It uses all 8 bits in a byte (2⁸ = 256 codes)
 The most standardised version is ISO Latin-1.
 It supports other european characters e.g. Ѯ, Ў, etc.
ASCII Code Disadvantages:
 It does not represent characters in non-Western languages, for example Chinese characters.
2. Unicode.



It support up to four bytes per character.// It can be of 8 bit, 16 bits, 24 bits, and 32 bits.
Unicode can represent all languages of the world, thus supporting many operating systems,
search engines and internet browsers used globally.
Represents all languages of the world.
Difference between ASCII and Unicode:
 UNICODE has greater range of characters than ASCII
 UNICODE represents most written languages in the world while ASCII does not ASCII
used for English only
 ASCII uses 7 bits (Extended ASCII uses 8 bits) whereas UNICODE uses up to 4 bytes per
character
 UNICODE is standardised while ASCII is not
IMAGE, AUDIO, & COMPRESSIONS:
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 32
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Pixel:
● Smallest picture element which can be drawn
● The smallest identifiable component of a bitmap image, defined by just two properties:
its position in the bitmap matrix and its colour
Colour Depth:
 The number of bits used to represent each colour/Pixel is called the colour depth.
 Increasing colour depth also increases the size of the file when storing an image.
Image Resolution:
● The number of pixels per unit measurement
● The number of pixels in an image
● The number of pixels wide(Row) by the number of pixels high(Column)
● Number of pixels per row by the number of rows
Screen Resolution:
● The number of pixels on the screens
● The number of pixels which can be viewed horizontally and vertically on the screen //
or by example - A typical screen resolution is 1680 pixels 1080 pixels.
Bitmap

Vector Graphics
● Bitmap is made up of pixels
● Vector graphic store a set of
instructions about how to draw the
shape
● Bitmap files are usually bigger than
vector graphics files
●
● Enlarging a bitmap can mean the
image is pixelated
● vector graphic can be enlarged
without the image becoming
pixelated
● Bitmap images can be compressed
(with significant reduction in file
size)
● Vector graphic
compress well
● Bitmaps are suitable for photographs
/ scanned images
● Vector graphics are suitable for more
geometric shapes
● Bitmap graphics use less processing
power than vector graphics
●
● Individual elements of a bitmap
cannot be grouped
● Individual elements of a vector
graphic can be grouped
●
● Vector graphics need to be
‘rasterized’ in order to display or print
For a bitmap a simple lossy compression
technique is to establish a coding scheme
with reduced colour depth. Then for
each pixel in the original bitmap the code
● It Uses Lossless Compression
images
do
not
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 33
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
is changed to the one in the new scheme
which represents the closest colour.
The following are considerations when justifying the use of either a bit map or a vector
graphic for a specific task.
 A vector graphic is chosen if a diagram is needed to be constructed for part of an
architectural, engineering or manufacturing design.
 If a vector graphic file has been created but there is a need to print a copy using a laser or
inkjet printer the file has first to be converted to a bitmap.
 A digital camera automatically produces a bitmap.
 A bitmap file is the choice for insertion of an image into a document, publication or web
page.
Bitmap File Header
● Confirmation that the file is a BMP
● File size
● Location/offset of image data within the file
● Dimensions of the image (in pixels) // image resolution
● Colour depth (bits per pixel, 1, 4, 8, 16, 24 or 32)
● Type of compression used, if any
A file header that contains information on how the graphic has been constructed. Because of
this, the bitmap file size is larger than the size of the graphic alone. At the very least the header
will define the colour depth or bit depth and the resolution.
Representation of sound
Sound waves are vibrations in the air. The human ear senses these vibrations and interprets
them as sound.
Each sound wave has a frequency, wavelength and amplitude. The amplitude specifies the
loudness of the sound.
Sound waves vary continuously. This means that sound is analogue. Computers
cannot work with analogue data, so sound waves need to be sampled in order to be
stored in a computer. Sampling means measuring the amplitude of the sound wave. This
is done using an analogue to digital converter (ADC).
To convert the analogue data to digital, the sound waves are sampled at regular
time intervals. The amplitude of the sound cannot be measured precisely, so
approximate values are stored.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 34
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Figure 1.9 shows a sound wave. The x-axis shows the time intervals when the sound was
sampled (1 to 21), and the y-axis shows the amplitude of the sampled sound to 10.
At time interval 1, the approximate amplitude is 10; at time interval 2, the approximate
amplitude is 4, and so on for all 20 time intervals. Because the amplitude range in Figure
1.9 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 .
Technical Term:
Sampling


Sampling means amplitude of sound wave taken at different points in time
measurement of value of analogue signal at regular time intervals/a point in time
Sampling Resolution
 Resolution is the number of distinct values available to encode/represent each sample
 Representation used to write samples in digital sound.
 specified by the number of bits used to store/record each sample
 the higher the sampling resolution the smaller the quantization error
 a higher sampling resolution results in less distortion of the sound usually 8 bit, 16 bit, 24
bit or 32 bit
Benefit allows for larger dynamic ranges as dynamic range is approximately six times the bit
depth more accurate representation/crisper sound quality Drawback bigger files/occupies
more memory/storage longer to transmit data/download music greater processing power
needed
Sampling rate
 The number of samples taken per unit time // the number of times the amplitude is measured
per unit time(per second)
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 35
Computer Science (9618)


Topical (Chap 1: Number System)
Paper1
higher sampling rate results in more accurate digital representation
Increasing the sampling rate will increase the accuracy / precision of the digitized sound //
Increasing the sampling rate will result in smaller quantisation errors.
Editing Sound software Features:
 edit start time, stop time and duration of any sound/timeline
 extract/delete/save part of a clip
 frequency, amplitude, pitch alteration
 fade in/out of a clip
 mix/merge multiple sound sources/tracks
 combine different sources at various volume levels
 pan between tracks/channels
 use of filters
 playback to speakers, processors or recording medium
 conversion between different audio file formats


Drawing List stores the list of shapes involved in an image // a list that stores the
command/description required to draw each object.
The properties include the basic geometric data such as, for a circle, the position of the
centre and its radius. In addition, properties are defined such as the thickness and style of a
line, the colour of a line and the colour that fills the shape.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 36
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Data compression
Data compression means reduce the file size by using Compression Algorithm.
Files Compression: the process of coding that will effectively reduce the total number of
bits needed to represent certain information. File compression is the process of encoding
information using fewer bits so that the compressed file size is smaller.
Reasons to reduce the File Size:






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
less bandwidth is required as Compressed files contain fewer bits of data than
uncompressed files and therefore use less bandwidth
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.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 37
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
File compression can either be Lossless or Lossy.
Lossy file compression
 With this technique, the file compression algorithm eliminates unnecessary bits of
 data permanently. This means the original file cannot be reconstructed once it has been
compressed.
 Used for compressing images and video files (our eyes cannot distinguish subtle
 changes, so lossy data is acceptable).
 The algorithms used in the lossy technique removes data that is not needed, either because
a drop in quality is acceptable or the difference cannot be detected by the human eye(Image
, Video e.g Jpg, MP4) or ear( Audio , Video e.g Mp3, MP4)
 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.
For example, when applying a lossy file compression algorithm to:
o an image, it may reduce the resolution and/or the bit/colour depth
o a sound file, it may reduce the sampling rate and/or the resolution.
 Common lossy file compression algorithms are:
o MPEG-3 (MP3) (Moving Picture Expert Group). Compressed Audio format
o MPEG-4 (MP4) (Moving Picture Expert Group). Compressed Video format
o JPEG (Joint Photographic Expert Group). Compressed Images
Note: It is impossible to get the original file back once it is compressed because it
eliminates the data permanently.
Lossless file compression:
 It uses compression algorithm(e.g Run Length Encoding(RLE)) to compress file.
 No data is removed in the process // original file can be restored
 Repeated words are identified (text file) // Repeated Patterns/Pixels are
identified(Images,audio,video) and are indexed
 During Compression repeated words are replaced with their index and their positions are
stored and the number of times the word/pattern appears is also stored
 With this technique, all the data from the original uncompressed file can be reconstructed.
 Lossless file compression is designed so that none of the original detail from the file is lost.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 38
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
Lossless and Lossy Compression






lossless designed to lose none of the original detail/lossless allows original file to be
recreated exactly
lossless technique based on some form of replacement for example RLE, FLAC etc. • by
example: e.g. 000–1111–222222–333 will become = 0–3, 1–4, 2–6, 3–3 etc.
lossy may result in loss of detail compared to original file/lossy does not allow original file
to be re-created exactly
lossy techniques make decision about what parts of sound/sound file are important and
discards other information
only keeps sounds human ear can process/discards sounds most people cannot hear then
applies lossless technique, for further reduction
lossy compression can reduce to about 10% • an example of jpeg, mp3 or other correct
examples of compressed formats.
Run length Encoding (An algorithm of Lossless Compression)
● Lossless method of compression.
● The repeating string/pixels (a run) is encoded into two values. This repeating string,
called a run ,typically divided into two values
● One value represents the number of time identical string/pixels are consecutively
repeated
● The other value is the code of the character / colour code of pixel etc
● The run value and run count combination may be preceded by a control character.
● E.g 000–1111–222222–333 will become = 0–3, 1–4, 2–6, 3–3 etc.
● In sound Where consecutive sounds are the same record the binary value of the sound
and number of times it repeats
Common lossless compression technique
 Run-length encoding.
o This works particularly well with a bitmap file. The idea is that compression
converts sequences of the same byte value into a code that defines the byte value
and the number of times it is repeated (the count). For example, the sequence of the
same four bytes:
01100110 01100110
could be replaced by:
00000100
01100110
01100110
01100110
which says that there is a run of four of the bytes.

Huff man coding.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 39
Computer Science (9618)
Topical (Chap 1: Number System)
Paper1
o This works particularly well with a text or sound file. Instead of having each
character coded in one byte, the text is analysed to find the most often used
characters. These are then given shorter codes. The original stream of bytes
becomes a bit stream.
Made By Madam Talat Jahangir (0333-5691967) O, A Level Computer Science Teacher Page 40
Download