0% found this document useful (0 votes)
434 views16 pages

A Level CS CH 1 9618

Computer Science notes covered information representation including: 1. Binary, decimal, and hexadecimal number systems and how to convert between them. 2. Common units of information storage like bytes and nibbles. 3. Maximum values and ranges that can be stored using a certain number of binary digits. 4. Internal coding of numbers including signed-magnitude and two's complement representations. 5. ASCII character encoding and Unicode for representing different languages. 6. Digital image representation including bitmaps, pixels, color depth, and vector graphics.

Uploaded by

calvin esau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
434 views16 pages

A Level CS CH 1 9618

Computer Science notes covered information representation including: 1. Binary, decimal, and hexadecimal number systems and how to convert between them. 2. Common units of information storage like bytes and nibbles. 3. Maximum values and ranges that can be stored using a certain number of binary digits. 4. Internal coding of numbers including signed-magnitude and two's complement representations. 5. ASCII character encoding and Unicode for representing different languages. 6. Digital image representation including bitmaps, pixels, color depth, and vector graphics.

Uploaded by

calvin esau
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Computer Science 9618 Notes Subject Teacher : Fahim Siddiq 03336581412

Unit 1 Information Representation


Decimal, Binary & Hexa decimal Numbers:
Conversion of numbers will be done in the class.

Byte: a group of eight bits treated as a single unit.


Nibble: a group of four bits.

Decimal Prefix:

Binary Prefix:

Max and range

The maximum denary value one can store in a set number of binary digits, or alternatively, the range of
values that one can store in a set number of binary digits. Read carefully, these are not the same thing.

Consider the following example:

If I were to have 3 binary digits, the maximum value that I could store would be 1112, this equates to 4 +
2 + 1 = 710.

If I were to be asked, the range of numbers then we have 8 options:

# 000
# 001
# 010
# 011
# 100
# 101
# 110
# 111
We could count these all out and write down: "There are 8 different values 3 binary digits can take". But
this isn't very clever, if one wants to find out the range and maximum values for 34 bits, one can't be
expected to write them all out. We are looking for a rule to save us the job and stop us making mistakes.

Maximum denary value of binary digits:

Rule: Max

Maximum denary value =

For example, for 3 digits: As calculated previously

Number of different values for binary digits:

Rule: Range

Number of values =

For example, for 3 digits: As calculated previously

Exercise: Max and range of binary numbers

For an address bus with 6 wires, what is the highest address that can be given? How many addresses can
accessed?

Internal Coding of Numbers:

Signed & Magnitude Method: Class discussion.

Drawbacks of Signed & Magnitude: Class discussion.

One's complement: the binary number obtained by subtracting each digit in a binary number from
1(it means converting each 0 to 1 and each 1 to zero)
Two's complement: the one's complement of a binary number plus 1.
One of the advantages of using two’s complement representations is that it simplifies the process of
subtracting one number from another. The number being subtracted is converted to its two’s complement
form, which is then added to the other number.

Computers store integers in two’s complement form.


Binary Arithmetic:

Denary Addition: Class Discussion.

Binary Addition & Subtraction:

Overflow: a condition when the result of a calculation is too large to fit into the number of bits
defined for storage.
ASCII

The 104-key PC US English QWERTY keyboard layout evolved from the standard typewriter keyboard,
with extra keys for computing.

ASCII normally uses 8 bits (1 byte) to store each character. However, the 8th bit is used as a check digit,
meaning that only 7 bits are available to store each character. This gives ASCII the ability to store a total
of

2^7 = 128 different values.


The 95 printable ASCII characters, numbered from 32 to 126 (decimal)

ASCII values can take many forms:

• Numbers
• Letters (capitals and lower case are separate)
• Punctuation (?/|\£$ etc.)
• non-printing commands (enter, escape, F1)

Take a look at your keyboard and see how many different keys you have. The number should be 104 for
a windows keyboard, or 101 for traditional keyboard. With the shift function valus (a, A; b, B etc.) and
recognising that some keys have repeated functionality (two shift keys, the num pad). We roughly have
128 functions that a keyboard can perform.

If you look carefully at the ASCII representation of each character you might notice some patterns. For
example:

Binary Dec Hex Glyph


110 0001 97 61 a
110 0010 98 62 b
110 0011 99 63 c

Example: ASCII characters

As you can see, a = 97, b = 98, c = 99. This means that if we are told what value a character is we can
easily work out the value of subsequent or prior characters.

Without looking at the ASCII table above! If we are told that the ASCII value for the character '5' is 011
0101, what is the ASCII value for '8'.

We know that '8' is three characters after '5', as 5,6,7,8. This means that the ASCII value of '8' will be
three bigger than that for '5':

011 0101 ASCII '5'


+ 011
--------
011 1000 ASCII '8'

Checking above this is the correct value.

If you are worried about making mistakes with binary addition, you can deal with the decimal numbers
instead. Take the example where you are given the ASCII value of 'g', 110 0111, what is 'e'?

We know that 'e' is two characters before 'g', as e, f, g. This means that the ASCII value of 'e' will be two
smaller than that for 'g'.
64 32 16 8 4 2 1
1 1 0 0 1 1 1 = 10310 = ASCII value of 'g'

103 - 2 = 10110

64 32 16 8 4 2 1
1 1 0 0 1 0 1 = 10110 = ASCII value of 'e'

Exercise: ASCII

The ASCII code for the letter 'Z' is 90(base10), what is the letter 'X' stored as

How many ASCII 'characters' does the following piece of text use:

Hello Pete, ASCII rocks!

Unicode

The problem with ASCII is that it only allows you to represent a small number of characters (~128 or 256
for Extended ASCII). This might be OK if you are living in an English speaking country, but what happens
if you live in a country that uses a different character set? For example:

• Chinese characters 汉字
• Japanese characters 漢字
• Cyrillic Кири́ ллица
• Gujarati ગુજરાતી
• Urdu ‫اردو‬

You can see that we quickly run into trouble as ASCII can't possibly store these hundreds of thousands of
extra characters in just 7 bits. What we use instead is unicode. There are several versions of unicode,
each with using a different number of bits to store data:

There are two methods to represent negative numbers (sign and magnitude method and two’s
complement form)

Uses of BCD
1. To display digital display such as screen of calculator and watch (BIOS of many personal computers
store time and date in BCD)
2. To represent fixed point decimal number such as currency $30.25
3. Hardware Algorithms (procedures) are east to implement on BCD codes.
Images
A digital image is a numeric representation (normally binary) of a two-dimensional image.

A large part of using modern computers involves sending pictures and films to each other, along with
using a graphical user interface. All of this involves computers saving and processing images. This section
will cover the two main image types: vector and bitmap, along with some compression techniques.

A comparison between a vector and bitmap representation of an image

Bitmap Graphics - a collection of pixels from an image mapped to specific memory locations holding
their binary colour value.

Pixel - the smallest possible addressable area defined by a solid colour, represented as binary, in an
image.

Image Resolution - how many pixels an image contains per inch/cm.

Screen Resolution - the number of pixels per row by the number of pixels per column.

Example: Calculating screen resolutions

Using the diagram above we are going to work out how many pixels are required to display a single
frame on a VGA screen.

Checking the resolution:

Height = 480
Width = 640
Area = Width * Height = Total Pixels
Area = 640 * 480 = 307200

Exercise:

Q: What is a Pixel?

A: The smallest possible addressable area defined by a solid colour, represented as binary, in an image.

Q: What is Image Resolution?

A: The amount of pixels an image contains per inch/cm.

Q: What is Screen Resolution?

A: The number of pixels per row by the number of pixels per column.

Q: What is the resolution of a 100 pixel by 70 pixel image?

A: 100 * 70 = 7000 pixels.

Q: If I have an image resolution of 700 pixels, and the height is 35, what is the width of the image?

A: 700 / 35 = 20 pixels.

Q: What is a benefit of having a higher resolution image?

A: Higher resolution images are able to display more detail, providing crisper images.

Q: What might be a draw back of having a very high resolution image?

A: It will require a lot of space to store it. Meaning you'll quickly run out of memory, or it'll take a long
time to transmit images across the internet or other data route.

Colour depth - The number of bits used to represent the colour of a single pixel.

Bit depth - The number of bits used to represent each of the red, green and blue colours.

Exercise:

Q: For a colour depth of 8 bits, how many colours could each pixel store?

A:

Q: To represent 1024 colours per pixel, what colour depth would I need?

A:
Q: For an image of 30 by 40 pixels, what would the file sizes be for the following colour depths 4 bits?

A:

Q: When might one want to decrease the colour depth for an image?

A: When you want to save file space or when you only need a specific palate of colours such a mono-
chrome.

Vector Graphics: a graphic consisting of components defined by geometric formulae and associated
properties, such as line colour and style

Drawing list - a set of commands used to define a vector image.

Vector graphics are made up of objects and their properties. An object is a mathematical or
geometrically defined construct such as a rectangle, line or circle.

<rect ... />


<line ... />
<circle ... />

Drawing object: a component defined by geometric formulae and associated properties.


Property: defines one aspect of the appearance of the drawing object.

Comparison between vector and bitmaps:


This image illustrates the difference between bitmap and vector images. The bitmap image is composed
of a fixed set of dots (pixels), while the vector image is composed of a fixed set of shapes. In the picture,
scaling the bitmap reveals the pixels and scaling the vector image preserves the shapes

• Vector images scale without file size increase / decrease


• Bitmap images scale resulting in file size increase / decrease
• Vector images scale without distortion to the image
• Bitmap images distort (pixellate) when scaling
• Bitmaps are better for photo editing
• Bitmaps require less processing power to display
• 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.

A bitmap file has to store the pixel data that defines the graphic, but the file must also have 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.

File header: A set of bytes at the beginning of a bitmap file which identifies the file and contains
information about the coding used.

Exercise:

Q: You wish to create an image that will be made into a giant banner for the side of a building. What
type should you use and why?

A: Vector, as it allows for scaling without distortion and retaining its file size.

Q: You wish to create an image that will be used in a game, that will run on a mobile phone and a home
console. What type should you use and why?

A: Vector, as it allows for scaling without distortion and retaining its file size. You would only need one
image to use on all the different systems

Q: You want to take an image of a local cat stuck in a tree. What type should you use and why?

A: Bitmap as it is better for photographs.


Sound

Sound waves in nature are continuous, this means they have an almost infinite amount of detail that
you could store for even the shortest sound. This makes them very difficult to record perfectly, as
computers can only store discrete/ digital data, data that has a limited number of data points.
The discrete approximations (in red) can be used to
Sound is a continuous set of data points recreate the original sound (grey). However, due to
formed by a wave. Computers sample this limitations in the number of samples we take we are
sound at discrete points to store a digital often unable to truly represent a sound wave, though
approximation we can get close enough for the human ear not to notice
the difference.

For a computer to store sound files we need to get the continuous analogue sound waves into discrete
binary values:

Analogue to Digital Converter (ADC) - Converts analogue sound into digital signals that can be stored on
a computer

Digital to Analogue Converter (DAC) - Converts digital signals stored on a computer into analogue sound
that can be played through devices such as speakers

Exercise:

Q: What is the difference between analogue and digital data?

A: Analogue data is continuous, allowing for an infinite number of possible values. Digital data is
discrete, allowing for a finite set of values.

Q: Name the device used by computers to convert sound files into sound coming out of the speaker

A: Digital to Analogue converter

Q: Name a peripheral that could be used to feed sound into a ADC


A: A microphone

Q: Why is it difficult to save analogue sound waves in a digital format?

A: Analogue is continuous data, converting continuous data to discrete values may lose some of the
accuracy.

So we should know by now that sound waves are continuous and computers can only store discrete
data. How exactly does an Analogue to Digital Converter convert a continuous sound wave into discrete
digital data? To do this we need to look at how computers sample sound.

Sampling - is the reduction of a continuous signal to a discrete/ digital signal.

Sampling Rate - The number of samples taken per second.


Hertz (Hz) - the SI unit of frequency defined as the number of cycles per second of a periodic
phenomenon.

Sampling resolution - the number of bits assigned to each sample.


As you saw earlier, different sounds can have different volumes. The sampling resolution allows you to
set the range of volumes storable for each sample. If you have a low sampling resolution then the range
of volumes will be very limited, if you have a high sampling resolution then the file size may become
unfeasible. The sampling resolution for a CD is 16 bits used per sample.

Bit rate - the number of bits required to store 1 second of sound.


To work out the size of a sound sample requires the following equation:

File Size = Sample Rate * Sample Resolution * Length of sound

This is the same as saying:

File Size = Bit Rate * Length of sound

If you wanted to record a 30 second voice message on your mobile phone you would use the following:

Sample Rate = 8,000Hz


Sample Resolution = 16 bit
Length of Sound = 30 seconds

Therefore the total file size would be:


8,000 * 16 * 30 = 3 840 000 Bits = 480 000 Bytes

Exercise: Sampled sound

Q: Why might a digital representation of a sound struggle to be a perfect representation?

Answer :
A sound wave is continuous data, whilst digital data is discrete and the representation is an
approximation of the original

Q: Why might you choose to have a lower sampling rate than a higher one for storing a song on your
computer?

Answer :
Q: The higher the sampling rate the more data is needed to be stored, meaning the larger the file size.

What is the sampling resolution?

Answer :
the number of bits assigned to each sample, effecting the range of volumes that can be stored in a
sample

Q: What is the equation to work out the bit rate of a song

Answer :
Sampling Rate * Sampling Resolution

Q: For the following sound sample work out its size:

Sample Rate = 16,000Hz


Sample Resolution = 8 bit
Length of Sound = 10 seconds

Answer :
16,000 * 8 * 10 = 1 280 000 Bits
Q: Work out the sample rate of the following sound file:

Sound File = 100,000 bits


Sample Resolution = 10 bit
Length of Sound = 5 seconds
Answer :
100,000 / (10 * 5) = 2,000Hz
Q: Why might a song recorded with the following settings:

Sample Rate = 22,000Hz


Sample Resolution = 16 bit
Length of Sound = 10 seconds

have a file size of 7,040,000 bits?


Answer :
The file might be recorded in stereo, meaning twice the amount of data would have to be stored.

Sound Compression:
As you are probably aware an mp3 of the same length would be roughly 3Mb, a fifth of the size. So what
gives? It is easy to see that the raw file sizes for sounds are just too big to store and transmit easily, what
is needed it a way to compress them.
Lossless
Lossless compression - compression doesn't lose any accuracy and can be decompressed into an
identical copy of the original audio data

WAV files don't involve any compression at all and will be the size of files that you have calculated
already. There are lossless compressed file formats out there such as FLAC which compress the WAV file
into data generally 50% the original size. To do this it uses run length encoding, which looks for
repeated patterns in the sound file, and instead of recording each pattern separately, it stores
information on how many times the pattern occurs in a row. Let us take a hypothetical set of sample
points:

0000000000000000000001234543210000000000000000000123456787656789876

As you can see the silent area takes up a large part of the file, instead of recording these individually we
can set data to state how many silent samples there are in a row, massively reducing the file size:

(21-0)123454321(17-0)123456787656789876

Another technique used by FLAC files is Linear prediction.


Lossy
FLAC files are still very large, what is needed is a format that allows you to create much smaller file sizes
that can be easily stored on your computer and portable music device, and easily transmitted across the
internet.
Lossy compression - compression loses file accuracy, generally smaller than lossless compression
There are many lossy compressed audio formats out there including: MP3, AAC and OGG (which is open
source). The compression works by reducing accuracy of certain parts of sound that are considered to
be beyond the auditory resolution ability of most people.
Exercise: Sound compression

Q: Why is it necessary to compress sound files?

Answer :
So that they take up less space and can be sent quickly across the internet or stored on portable music
players

Q: Name the two categories of compression available and give a file format for each

Answer :
Lossy (mp3/AAC/ogg) and lossless(FLAC)

Q: perform run length encoding on the following sound file

012344444444444432222222222222211111111111111000000000000
Answer :
0123(11-4)3(13-2)(14-1)(11-0)

Q: Describe a technique used to compress mp3 files

Answer :
perceptual coding reduces the quality of frequencies stored in a sound file that are beyond the auditory
resolution of most people

Q: When would it be best to use FLAC instead of ogg and vice-versa?

Answer :

• when you really care about the sound quality and you're not bothered about the file size
• when you are trying to make a sound file as small as possible

You might also like