0% found this document useful (0 votes)
9 views12 pages

Chapter 1 - Notes

Uploaded by

nithivpandian5
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)
9 views12 pages

Chapter 1 - Notes

Uploaded by

nithivpandian5
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/ 12

COMPUTER SCIENCE O LEVELS - 2210

Chapter 1: Data Representation


Binary represents data
• The basic building block in all computers is the binary number system.
• This system is chosen because it only consists of 1s and 0s.
• Since computers contain millions and millions of tiny ‘switches’, which must be in the ON or OFF
position.
• A switch in the ON position is represented by 1; a switch in the OFF position is represented by 0.

Number systems
1. Binary systems
The binary number system is a base 2 number system. It is based on the number 2. Thus, only the two
‘values’ 0 and 1 can be used in this system.

2. Denary systems
Denary uses ten separate digits, 0-9, to represent all values. Denary is known as a base 10 number
system.

3. Hexadecimal system
Hexadecimal (sometimes referred to as simply ‘hex’) is a base 16 system and therefore needs to use 16
different ‘digits’ to represent each value.Because it is a system based on 16 different digits, the numbers 0
to 9 and the letters A to F are used to represent each hexadecimal (hex) digit. A in hex = 10 in denary, B =
11, C = 12, D = 13, E = 14 and F = 15
Since 16 = 24 this means that FOUR binary digits are equivalent to each hexadecimal digit. The following
table summarises the link between binary,hexadecimal and denary:

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 1
COMPUTER SCIENCE O LEVELS - 2210

Use of the hexadecimal system


A complex binary number, such as 1101001010101111 can be written in hex as D2AF. The hex number is
far easier for humans to remember, copy and work with.
This section reviews four uses of the hexadecimal system:
» error codes
» MAC addresses
» IPv6 addresses
» HTML colour codes
Error codes
Error codes are often shown as hexadecimal values. These numbers refer to the memory location of the
error and are usually automatically generated by the computer.
Media Access Control (MAC) addresses

• Media Access Control (MAC) address refers to a number which uniquely identifies a device on a
network.
• The MAC address refers to the network interface card (NIC) which is part of the device.
• The MAC address is rarely changed so that a particular device can always be identified no matter
where it is.
• A MAC address is usually made up of 48 bits which are shown as 6 groups of two hexadecimal
digits (although 64-bit addresses also exist):

NN – NN – NN – DD – DD – DD
or
NN:NN:NN:DD:DD:DD

• where the first half (NN – NN – NN) is the identity number of the manufacturer of the device and
the second half (DD – DD – DD) is the serial number of the device.
• For example:
00 – 1C – B3 – 4F – 25 – FE is the MAC address of a device produced by the Apple Corporation

Internet Protocol (IP) addresses


• Each device connected to a network is given an address known as the Internet
Protocol (IP) address.
• An IPv4 address is a 32-bit number written in denary or hexadecimal form: e.g. 109.108.158.1 (or
77.76.9e.01 in hex).
• IPv4 has recently been improved upon by the adoption of IPv6.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 2
COMPUTER SCIENCE O LEVELS - 2210

• An IPv6 address is a 128-bit number broken down into 16-bit chunks, represented by a
hexadecimal number.
For example:
a8fb:7a88:fff0:0fff:3d21:2085:66fb:f0fa
• Note IPv6 uses a colon (:) rather than a decimal point (.) as used in IPv4.
Compares the features of MAC addresses and IP addresses:

MAC addresses IP addresses


Identifies the physical address of a device on
Identifies the global address on the internet
the network
Unique for device on the network May not necessarily be unique
Assigned by the manufacturer of the device Dynamic IP addresses are assigned by ISP using
and is part of the NIC DHCP each time the device connects to the internet
Dynamic ip addresses change every time a device
They can be universal or local connects to the internet; static ip addresses don’t
change
When a packet of data is sent and received, the Used in routing operations as they specifically
MAC address is used to identify the sender’s and identify where the device is connected to the
recipient’s devices internet
Use 48 bits Use either 32 bits (ipv4) or 128 bits (ipv6)
Can be UAA or LAA Can be static or dynamic

HyperText Mark-up Language (HTML) colour codes


• HyperText Mark-up Language (HTML) is used when writing and developing web pages.
• HTML isn’t a programming language but is simply a mark-up language. A mark-up language is
used in the processing, definition and presentation of text (for example, specifying the colour of
the text).
• HTML is often used to represent colours of text on the computer screen. All colours can be made
up of different combinations of the three primary colours (red, green and blue). The different
intensity of each colour (red, green and blue) is determined by its hexadecimal value. This means
different hexadecimal values represent different colours. For example:
» # FF 00 00 represents primary colour red
» # 00 FF 00 represents primary colour green
» # 00 00 FF represents primary colour blue
» # FF 80 00 represents orange and so on producing almost any colour the user wants.
• The # symbol always precedes hexadecimal values in HTML code.
• The colour codes are always six hexadecimal digits representing the red, green and blue
components.
• There are a possible 256 values for red, 256 values for green and 256 values for
blue giving a total of 256 × 256 × 256 (i.e. 16 777 216) possible colours.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 3
COMPUTER SCIENCE O LEVELS - 2210

Addition of binary numbers


Note the following key facts when carrying out addition of two binary digits:

binary addition carry sum


0+0 0 0
0+1 0 1
1+0 0 1
1+1 1 0

This can then be extended to consider the addition of three binary digits:

binary digit carry sum


0+0+0 0 0
0+0+1 0 1
0+1+0 0 1
0+1+1 1 0
1+0+0 0 1
1+0+1 1 0
1+1+0 1 0
1+1+1 1 1
Overflow
The result of carrying out a calculation that produces a value that is too large for the computer’s allocated
word size (8-bit, 16-bit, 32-bit, and so on)

This addition has generated a 9th bit. The 8 bits of the answer are 0 1 0 0 1 1 0 0 – this gives the denary value (64 + 8 + 4) of 76
which is incorrect because the denary value of the addition is 110 + 222 = 332.

The maximum denary value of an 8-bit binary number is 255 (which is 28 – 1). The generation of a 9th bit is a clear indication
that the sum has exceeded this value. This is known as an overflow error and in this case is an indication that a number is too
big to be stored in the computer using 8 bits

For example, a 16-bit register would allow a maximum denary value of 65 535 (i.e. 216 – 1) to be stored, a 32-bit register would
allow a maximum denary value of 4 294 967 295 (i.e. 232 – 1), and so on.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 4
COMPUTER SCIENCE O LEVELS - 2210

Logical Binary Shifts


• The logical shift means moving the binary number to the left or to the right.
• Each shift left is equivalent to multiplying the binary number by 2 and each shift right is
equivalent to dividing the binary number by 2.
• As bits are shifted, any empty positions are replaced with a zero.
• There is clearly a limit to the number of shifts which can be carried out if the binary number is
stored in an 8-bit register.
• Eventually after a number of shifts the register would only contain zeros
• For example, if we shift 01110000 (denary value 112) five places left (the equivalent to
multiplying by 25, i.e. 32), in an 8-bit register we would end up with 00000000.
• This makes it seem as though 112 × 32 = 0! This would result in the generation of an error
message.

Two’s complement (binary numbers)


A method of representing negative numbers in binary; when applied to an 8-bit system, the left-most
bit (most significant bit) is given the value –128

In two’s complement the left-most bit is changed to a negative value.


For instance, for an 8-bit number, the value 128 is now changed to -128, but all the other headings
remain the same. This means the new range of possible numbers is: -128 (10000000) to +127
(01111111).

Text, sound and images


Character sets – ASCII code and Unicode
• ASCII code – a character set for all the characters on a standard keyboard and control codes.
• The ASCII code system (American Standard Code for Information Interchange)
The standard ASCII code character set consists of 7-bit codes (0 to 127 denary or 0 to 7F in
hexadecimal); this represents the letters, numbers and characters found on a standard keyboard.
• Consider the uppercase and lowercase codes in binary of characters. For example,

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 5
COMPUTER SCIENCE O LEVELS - 2210

• Notice the sixth bit changes from 1 to 0 when comparing lower and uppercase characters. This
makes the conversion between the two an easy operation.
• ASCII code has a disadvantage that it does not represent characters in non-Western languages, for
example Chinese characters.
• Extended ASCII uses 8-bit codes (128 to 255 in denary or 80 to FF in hex). This allows for non-
English characters and for drawing characters to be included.

Unicode
• Unicode can represent all languages of the world, thus supporting many operating systems, search
engines and internet browsers used globally.
• It produce a more efficient coding system than ASCII.
• Adopt uniform encoding where each character is encoded as 16-bit or 32-bit code.
• Reserve part of the code for private use to enable a user to assign codes for their own characters
and symbols (useful for Chinese and Japanese character sets, for example).

Representation of sound
Soundwaves 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.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 6
COMPUTER SCIENCE O LEVELS - 2210

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).
The amplitude of the sound cannot be measured precisely, so approximate values are stored.

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).
sampling resolution – the number of bits used to represent sound amplitude in digital sound recording
(also known as bit depth)
or
bit depth – the number of bits used to represent the smallest unit in a sound file.

In our example, the sampling resolution is 4 bits.Sampling rate is the number of sound samples taken
per second. This is measured in hertz (Hz), where 1 Hz means ‘one sample per second’.

How is sampling used to record a sound clip?


» the amplitude of the sound wave is first determined at set time intervals (the sampling rate).
» this gives an approximate representation of the sound wave.
» each sample of the sound wave is then encoded as a series of binary digits.
Using a higher sampling rate or larger resolution will result in a more faithful representation of the
original sound source. However, the higher the sampling rate and/or sampling resolution, the greater the
file size.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 7
COMPUTER SCIENCE O LEVELS - 2210

The benefits and drawbacks of using a larger sampling resolution when recording sound

Benefits Drawbacks
larger dynamic range produces larger file size
takes longer to transmit/download
better sound quality
music files
less sound distortion requires greater processing power

Representation of (bitmap) images


Bitmap images are made up of pixels (picture elements); an image is made up of a two-dimensional
matrix of pixels. Pixels can take different shapes such as:

Pixel – derived from the term 'picture element', this is the smallest element used to make up an image on
a display.
Each pixel can be represented as a binary number, and so a bitmap image is stored in a computer as a
series of binary numbers, so that:
» a black and white image only requires 1 bit per pixel – this means that each pixel can be one of two
colours, corresponding to either 1 or 0
» if each pixel is represented by 2 bits, then each pixel can be one of four colours (22 = 4), corresponding
to 00, 01, 10, or 11
» if each pixel is represented by 3 bits then each pixel can be one of eight colours (23 = 8), corresponding
to 000, 001, 010, 011, 100, 101, 110, 111.

The number of bits used to represent each colour is called the colour depth.
An 8 bit colour depth means that each pixel can be one of 256 colours (because 28 = 256).
Modern computers have a 24 bit colour depth, which means over 16 million different colours can be
represented With x pixels, 2x colours can be represented as a generalisation. Increasing colour depth also
increases the size of the file when storing an image.
Image resolution refers to the number of pixels that make up an image; for example, an image could
contain 4096 × 3072 pixels (12 582 912 pixels in total).
The main drawback of using high resolution images is the increase in file size.
As the number of pixels used to represent the image is increased, the size of the file will also increase.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 8
COMPUTER SCIENCE O LEVELS - 2210

It also impacts on the time to download an image from the internet or the time to transfer images from
device to device.
bitmap image – an image made up of pixels
pixelated (image) – this is the result of zooming into a bitmap image; on zooming out the pixel density
can be diminished to such a degree that the actual pixels themselves can be seen
pixel density – number of pixels per square inch
Data storage and file compression
Measurement of data storage
• A bit is the basic unit of all computing memory storage terms and is either 1 or 0.
• The word comes from binary digit.
• The byte is the smallest unit of memory in a computer.
• 1 byte is 8 bits.
• A 4-bit number is called a nibble – half a byte.
Memory size using denary values

The above system of numbering now only refers to some storage devices but is technically inaccurate. It
is based on the SI (base 10) system of units where 1 kilo is equal to 1000.
IEC memory size system

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 9
COMPUTER SCIENCE O LEVELS - 2210

This system is more accurate. Internal memories (such as RAM and ROM) should be measured using the
IEC system. A 64GiB RAM could, therefore, store 64 × 230 bytes of data (68719476736 bytes).

Calculation of file size


The file size of an image is calculated as:
image resolution (in pixels) × colour depth (in bits)

The size of a mono sound file is calculated as:


sample rate (in Hz) × sample resolution (in bits) × length of sample (in seconds)
For a stereo sound file, you would then multiply the result by two.

Data compression
Sound and image files can be very large. It is therefore necessary to reduce (or compress) the size of a
file for the following reasons:
» 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
» the download/upload process uses up network
Bandwidth – this is the maximum rate of transfer of data across a network, measured in kilobits per
second (kbps) or megabits per second (Mbps).
This occurs whenever a file is downloaded, for example, from a server. Compressed files contain fewer
bits of data than uncompressed files and therefore use less bandwidth, which results in a 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.

Lossy and lossless file compression


Compression – reduction of the size of a file by removing repeated or redundant pieces of data; this can
be lossy or lossless.
Lossy file compression
• With this technique, the file compression algorithm eliminates unnecessary data from the file.
• 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.
• This means the original file cannot be reconstructed once it has been compressed.

For example, when applying a lossy file compression algorithm to:


» an image, it may reduce the resolution and/or the bit/colour depth
» a sound file, it may reduce the sampling rate and/or the resolution.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 10
COMPUTER SCIENCE O LEVELS - 2210

Lossy files are smaller than lossless files which is of great benefit when considering storage and data
transfer rate requirements.
Common lossy file compression algorithms are:
» MPEG-3 (MP3) and MPEG-4 (MP4)
» JPEG.
MPEG-3 (MP3) (MP4)
A lossy file compression method used for music A lossy file compression method used for
files multimedia files
MP3 files are used for playing music on computers This format allows the storage of multimedia
or mobile phones. This compression technology files rather than just sound – music, videos,
will reduce the size of a normal music file by about photos and animation can all be stored in the
90%. MP4 format.

Q. How can the original music file be reduced by 90% while still retaining most of the music
quality?
Essentially the algorithm removes sounds that the human ear can’t hear properly. For example:
» removal of sounds outside the human ear range.
» if two sounds are played at the same time, only the louder one can be heard by the ear, so the softer
sound is eliminated. This is called perceptual music shaping.

JPEG
JPEG – from Joint Photographic Expert Group; a form of lossy file compression used with image files
which relies on the inability of the human eye to distinguish certain color changes and hues

The JPEG file reduction process is based on two key concepts:


» human eyes don’t detect differences in colour shades quite as well as they detect differences in image
brightness (the eye is less sensitive to colour variations than it is to variations in brightness)
» by separating pixel colour from brightness, images can be split into 8 × 8 pixel blocks, for example,
which then allows certain ‘information’ to be discarded from the image without causing any real
noticeable deterioration in quality.

Lossless file compression


• Lossless compression is where, after compression, the file is converted back into its original state,
without the loss of a single bit (binary digit) of data.
• When the lossless compression software sees a repeated sequence of bits it replaces the repeated
sequences with a special character which indicates what is being repeated and how many times.
• This type of compression is normally used with spreadsheets, databases and word-processed files, where
the loss of just one bit could change the meaning completely.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 11
COMPUTER SCIENCE O LEVELS - 2210

Q. How data is compressed using lossy and lossless compression.

Lossy

- A (compression) algorithm is used which removes redundant/unnecessary data from the file.
- It also rremoves sounds that cannot be heard by the human ear/background noise
- Reduces sample rate and sample resolution.
- Data is permanently removed // original file cannot be re-instated
- Perceptual music shaping is used

Lossless:
- A (compression) algorithm is used in which repeating patterns are identified and are replaced with a
value or indexed
- No data is permanently removed and original file can be re-instated
- Example of a lossless algorithm is RLE – Run length encoding.

Run length Encoding (RLE) – a lossless file compression technique used to reduce the size of text and
photo files in particular
» it is a form of lossless/reversible file compression.
» it reduces the size of a string of adjacent, identical data (e.g. repeated colours in an image)
» a repeating string is encoded into two values:
– the first value represents the number of identical data items (e.g. characters) in the run.
– the second value represents the code of the data item (such as ASCII code if it is a keyboard character).
» RLE is only effective where there is a long run of repeated units/bits.

HTTPS://WWW.YOUTUBE.COM/@86WAQARKHAN 12

You might also like