Professional Documents
Culture Documents
Computer Science AS Level - S1-Chapter 1 (IR)
Computer Science AS Level - S1-Chapter 1 (IR)
1.1.1. Number representation
Types of Number Systems
a.) Binary Number Systems
b.) Denary/ Decimal Number Systems
c.) Hexadecimal Number Systems
d.) Octal Number Systems
Term: The binary number system is a base-2 system which uses just two symbols, 0 and 1. These
binary digits are usually referred to as 'bit s'.
● All data inside a computer system are stored and manipulated using a binary code. However,
if there is ever a need to document some of this binary code outside of the computer system
it is not helpful to use the internal code.
Term: Each binary digit is also called a bit. Binary number system is also positional value system,
where each digit has a value expressed in powers of 2, as displayed here.
In any binary number, the rightmost digit is called least significant bit (LSB) and leftmost digit is
called most significant bit (MSB).
And decimal equivalent of this number is sum of product of each digit with its positional value.
= 16 + 8 + 0 + 2 + 0
= 2610
Computer memory is measured in terms of how many bits it can store. Here is a chart for memory
capacity conversion.
❖ 1 Zettabyte = 1024 EB
This means that the value of digits will depend on its position. Let us take an example to understand
this.
Say we have three numbers – 734, 971 and 207. The value of 7 in all three numbers is different−
In digital systems, instructions are given through electric signals; variation is done by varying the
voltage of the signal. Having 10 different voltages to implement decimal number system in digital
equipment is difficult.
c.) Hexadecimal Number Systems:
Term: Hexadecimal numbers are in the base-16 system and therefore require 16 individual symbols
to represent a number. The symbols chosen are 0-9 supplemented with A- F.
as its value
Hexadecimal number system is also a positional value system with where each digit h
expressed in powers of 16, as shown here −
A few examples of the hexadecimal representation of binary numbers represented by eight bits are
shown in Table 1.01.
Note that each grouping of four bits is represented by one hexadecimal symbol. Also note that it is
common practice to include leading zeros in a hexadecimal number when used in this way.
Decimal equivalent of any hexadecimal number is sum of product of each digit with its positional
value.
= 1023410
Term: The number system whose base is 8 is known as the octal number system. The b
ase 8
means the system uses eight digits from 0 to 7.
All the eight digits from 0 to 8 have same physical meaning as that of decimal numbers. The
next digit in octal number is represented by 10, 11, 12, 13, 14, 15, 16, 17 which represents
the decimal digits 8, 9, 10, 11, 12, 13, 14, 15. In this manner the octal number 20 represents
the decimal number 16 and subsequently 21, 22, 23….octal numbers will show the decimal
digits 17, 18, 19…etc and so on.
Number Systems Relationships
The following table depicts the relationship between decimal, binary, octal and hexadecimal number
systems.
0 0 0 0000
1 1 1 0001
2 2 2 0010
3 3 3 0011
4 4 4 0100
5 5 5 0101
6 6 6 0110
7 7 7 0111
8 8 10 1000
9 9 11 1001
A 10 12 1010
B 11 13 1011
C 12 14 1100
D 13 15 1101
E 14 16 1110
F 15 17 1111
To convert a binary number to a denary number the straightforward method is to sum the individual
position values knowing that the least significant bit represents 2°, the next one 21 and so on. This is
illustrated by conversion of the binary number 11001 as shown in Figure 1.01.
Below given examples contains the following rows: (Common for all conversions)
A) Row 1 contains the DIGITs of number (that is going to be converted).
B) Row 2 contains the POSITION of each digit in the number system.
C) Row 3 contains the multiplication: DIGIT* BASE^POSITION.
D) Row 4 contains the calculated result of step C.
E) And then add each value of step D, resulted value is the Decimal Number
=12288+0+0+56+1
=12345-Decimal Number is: (12345)10
=512+208+5
=725
Decimal Number is: (725)10
Decimal to Binary
Decimal to Octal
Decimal to Hexadecimal
Here is an example of using repeated division to convert 1792 decimal to hexadecimal:
Decimal: 0 1 2 3 4 5 6 7
Hexadecimal
0 1 2 3 4 5 6 7
:
Decimal: 8 9 10 11 12 13 14 15
Hexadecimal
8 9 A B C D E F
:
To convert a hexadecimal number to binary, each digit is treated separately and converted
into a 4-bit binary equivalent, remembering that F converts to 1111; E converts to 1110 and
so on. Subsequent conversion of the resulting binary to denary can then be done if needed.
To convert a binary number to hexadecimal you start with the four least significant bits and
convert them to one hexadecimal digit. You then proceed upwards towards the most
significant bit, successively taking groupings of four bits and converting each grouping to the
corresponding hexadecimal digit. It is possible to convert a denary number directly to
hexadecimal but it is easier to convert first to binary before completing the conversion.
1.1.1. A. Internal Coding of Numbers
Terms
Samples are being taken every one millisecond; that is, 1000 samples will be taken every
second. This example used only eight bits to store each sample. Figure 1.05 shows the
sampled data values stored in main memory from address 300 onwards.
It should be apparent from Figure 1.05 that:
• If samples are taken more frequently, the quality of the sound wave will increase.
• If a larger number of bits is used to encode each sample, the sound resolution will increase.
Sound editing software is used for the recording of:
• Spoken word using a microphone • the ‘digitising’ of an analogue sound source. An example
could be the connection of a record turntable to the computer. The sound from a vinyl record is
then recorded using the sound recording software
Editing features of the software would include:
• Cutting and pasting of sections of the recording
• Filtering out certain sounds. For example the ‘clicks’ on a scratched vinyl record
• Recording as a single (mono) channel or two channels (stereo)
• Normalising the recording level
• Export of the sound recording to a variety of file formats. For example MP3.
300 301 302 303 304 305 306 307 308 309
8 20 35 44 38 38 48 61 69 75
310 311 312 313 314
75 57 45 36 29
Figure 1.05
1.1.4 VIDEO
Video is in widespread use on computers for recreational and educational use:
• YouTube is one of the most popular websites where users can post their own video content.
• Videos are an excellent medium for an explanation of the working of a piece of equipment
or to provide a learning tutorial.
A video is a sequence of still photographic images which are displayed in sequence. The
frequency with which they are displayed gives the appearance of continuous motion, and what
is contained on individual frames is not apparent. The frequency with which the frames are
displayed is called the frame rate. A continuous effect to the human eye is achieved with a
frame rate of 25 frames per second or higher.
Frame rate: the frequency with which video
Frames are displayed
Progressive encoding
A system which stores the data for an entire frame and displays all the frame data at the
same time is called ‘progressive encoding’. This means the frame rate will be the number of
pictures displayed per second. Traditional Film uses progressive encoding.
Interlaced encoding
The problem is that some devices, such as a television, are not designed to display all the
frame data at the same time. The data from a single frame is encoded as two separate fields;
one containing the data for the even numbered rows and the second frame has the data for
the odd numbered rows. The term interlaced comes from the concept that the image is
rendered by switching between the even field and the odd field. It follows that the rate of
picture display is twice the frame rate.
With increasing demand for the display of video content through DVD players, set-top boxes
and other home electronic devices there is still a need for interlaced encoded video format i
les. The picture frames that make up interlaced fields have a correct order relative to each
other:
• The spatial order shows which should be the odd or even field.
• The temporal order refers to a field or frame and which field represents an earlier moment
in time.
If either one or both of these orders is incorrect the result of the playback will appear as jerky
motion or blurred edges to content.
1.1.5 Compression Techniques
Both sound and video files tend to have large file size. Techniques used which encode the data
in a way which results in less byte for the file are highly desirable. Compression is the
technique of reducing the size of a file without a significant loss in the later quality in the use
of the file.
There are two categories of compression.
The first is lossless compression where the file size is reduced but no information is lost and
when necessary the process can be reversed to re-create the original file.
The second is lossy compression where the file size is reduced with some loss of information
and the original file can never be recovered. In many applications a combination of lossless
and lossy methods may be used.
Lossless compression: coding techniques that allow subsequent decoding to recreate exactly the
original file
Lossy compression: coding techniques that cause some information to be lost so that the exact
original file cannot be recovered in subsequent decoding
Image compression techniques
Run-length encoding (RLE) Consider a bitmapped file of a photograph where over half of the
pixels are the same pixel value, representing the blue sky. An alternative to saving (say) the
300 consecutive pixel values on a row could be to save a single copy of the pixel value
followed by the number of occurrences of the value (300). This way we have reduced the
number of pixels used to store this portion of the graphic from 300 to a very small number.
This technique would be appropriate for a monochrome image consisting of a black line
drawing on a white background. This will contain ‘runs’ when horizontal or vertical straight line
are drawn. Consider a 256-colour image that is 30 x 4 pixels as shown in Figure 1.06. The
image has four different colours, coded as w, b, r and g.
Lossless encoding
We now have two alternatives for encoding a bitmapped image:
• Save the colour code for every pixel.
• Use run-length encoding. Both of these techniques mean that the original bitmap can be
re-created when the data is read from the bitmap image i le and displayed on the output
device. For bitmap files several of the universal file formats are lossless. These include .bmp
and the Portable Network Graphics (.png) format, which was intended as a replacement for
the older .gif format.
Lossy encoding
Using a ‘lossy’ technique for encoding bitmap data has the objective of compressing the file
size. Lossy techniques are based on two concepts which exploit the limitations of the human
eye:
• An image which has a large background could encode the background pixels with a lower
resolution.
• Colours such as blue, to which the human eye is less sensitive, could be encoded at a lower
resolution.
The popular .jpeg file format is lossy.
Video compression techniques
Since a video is made up of a number of frames, we are interested in applying various
compression techniques to a video frame or a frame sequence.
Spatial redundancy
This is the similar to the concern over ‘redundancy’ in a bitmap file. Is there a sequence of the
same pixels within a single frame which could be encoded or effectively compressed?
Temporal redundancy
Is there a sequence of similar pixels in the same position in consecutive frames? In which case,
we do not need to repeat them in each frame. It will depend entirely on the content. A room
full of people disco-dancing will not compress as well as a panoramic view of a beauty spot.
Interframe coding addresses the issue of temporal redundancy. The encoding method is
based on the idea of key frames, which store data for all the picture, and intermediary
frames which store only the differences from the next intermediary frame or key frame.
File Formats
Over the years standards in the computing industry have emerged for image files (we have
already mentioned .BMP, .PNG, .GIF and .JPEG) and sound data. Popular sound formats
include .WAV, .MPEG and .MP3.
Video – which is a combination of moving pictures and sound – requires its own industry
standards. The detail about encoding methods used for this is outside the scope of our
syllabus. The key issue is that there is correct synchronisation between the picture display and
the accompanying sound commentary.
The current popular multimedia container formats include:
• AVI (standard Microsoft Windows container)
• MOV (standard QuickTime container)
• MP4 (standard container for MPEG-4 multimedia)
• Matroska (not standard for any codec or system, but it is an open standard).
The differences between container formats arise from issues such as:
• Popularity: is the container format widely supported? This is the reason that the AVI format is
still the most popular format.
• Overheads: This refers to the difference in file size between two files with the same content
in a different container. For a two-hour film, an AVI file may be up to 10 MB larger than a
file in Matroska format.
• Support for advanced codec functionality: Older formats, such as AVI, do not support new
codec features, such as streaming media.
Summary
shape libraries provided by the
❖ Numbers can be written using a software. Each object has a set of
binary, denary or hexadecimal properties which are stored as part
base. of the vector file.
❖ Two’s complement is a ❖ Sound is encoded as samples taken
representation which allows both from the analogue source with a set
positive and negative integers to sampling rate. The number of bits
be represented. used to encode each sample (the
❖ Binary-coded decimal (BCD) is a sampling resolution) determines the
coding system used for positive sound quality.
integers. ❖ Video is made up of a sequence of
❖ Images can be encoded as a image frames with an
bitmap, made up of a rectangular accompanying sound track. The
grid of pixels. The file header will encoding can be interlaced or
contain data about the image: its progressive. Various multimedia
height, width and the type of formats are used commercially.
bitmap. Bitmap resolutions are These formats may uses
monochrome, 16 colour, 256 colour compression techniques to address
and true colour. From the resolution spatial and temporal redundancy.
and the dimensions, the file size can ❖ Compression techniques use either
be calculated. ‘lossy’ or ‘lossless’. One lossless
❖ Vector graphics are constructed technique is run-length encoding
using drawing objects selected from (RLE).