0% found this document useful (0 votes)
13 views

GCSE Revison Guide - Chapter 1

The document provides a comprehensive overview of data representation in computer science, covering conversions between number systems (denary, binary, hexadecimal), binary addition, and two's complement for negative integers. It discusses the advantages and uses of hexadecimal systems, MAC addresses, error codes, HTML colors, IP addresses, ASCII, Unicode, and file compression techniques. Additionally, it explains sound and image capture, sampling, and run-length encoding for data compression.

Uploaded by

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

GCSE Revison Guide - Chapter 1

The document provides a comprehensive overview of data representation in computer science, covering conversions between number systems (denary, binary, hexadecimal), binary addition, and two's complement for negative integers. It discusses the advantages and uses of hexadecimal systems, MAC addresses, error codes, HTML colors, IP addresses, ASCII, Unicode, and file compression techniques. Additionally, it explains sound and image capture, sampling, and run-length encoding for data compression.

Uploaded by

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

IGCSE Computer Science

Revision Guide – Chapter 1


…………………………………………………………………………………………………………………………………………………………

Data Representation
Memory Units

Conversions between number systems


Denary to Binary
 First set up the columns of base 2 numbers. (e.g. 84)
 Then look for the highest 2n number that goes into 84 and place a 1 in the corresponding column. The
highest 2n number is 64. Then subtract this from your number. 84 – 64 = 20
 Once you have reached zero fill in the gaps with 0s.

(84 – 64 = 20 20 – 16 =4 4 - 4 = 0)

Denary to Hexadecimal
Divide by 16 - Read the remainders from the bottom up

Example: 2004

2004 / 16 = 125 remainder 4

/ 16 = 7 remainder 13

/ 16 = 0 remainder 7

Answer = 7 D 4 (13 is D in Hex)

Binary to Denary
When calculating the value of a binary number each time a 1 appears in a column, the column value is added to
the total The 0 values are simply ignored. E.g.

A typical binary number would be: 11101110 128 + 64 + 32 + 8 + 4 + 2 = 238 (denary)

Binary to Hexadecimal
Starting from the right split the number into groups of 4 bits

If a group has less than 4 fill with 0s from the left

Convert each group into hexadecimal using the table

Example - 1 0 0 0 0 1 1 1 1 1 1 1 0 1
First split this up into groups of 4 bits:

The left group only contains 2 bits, so add in two 0s:

Now use Table 1.2 to find the equivalent hexadecimal digits:

Hexadecimal to Denary
 Write the base 16 headings
 Multiply each hex digit by its base heading
 Add the answers together

Example: F4 (Note: in Hex F = 15, C = 12)

(15 x 256) + (4 x 16) + (12 x 1) = 3916

Hexadecimal to Binary
 Using Table find the 4-bit code for each digit:
 Put the groups together to form the binary number:
 45A=010001011010

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

Example:

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 - see examples.
Problems with shifting bits

 May run out of places at the end of the register


 End bit may be lost
 May result in a loss of precision

Two’s compliment
 To allow the possibility of representing negative integers we make use of two's complement.
 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).
 It is important to realise when applying two's complement to a binary number that the left-most bit always
determines the sign of the binary number.
 A 1-value in the left-most bit indicates a negative number and a 0-value in the left-most bit indicates a
positive number (for example, 00110011 represents 51 and 11001111 represents -49).

EXAMPLE HERE ???

Hexadecimal Systems
Advantages

 Easier to understand
 Easier to debug
 Shorter so takes up less space
 Faster to enter than binary
 Conversion to binary easier than from denary

Uses

 MAC address - 01-23-45-67-89-AB-CD


 Error messages - #404 page not found
 HTML colours - blue 0000FF
 IP Addreses - 109.108.158.1 (or 77.76.9e.01 in hex).
 ASCII & Uniode

MAC Addresses
 Hardware Address
 Unique number associated with a device
 Usually 48/64 bits (12/16 hex digits)
 First 6/8 digits = manufacturer code
 Last 6/8 digits = serial number of device
 UAA (Most Common)
 LAA (Can be changed)
Why change MAC address

 on mainframe systems all MAC addresses of devices may need to fall into a strict format
 to bypass a MAC address filter on a router or a firewall
 To get past certain types of network restrictions it may be necessary to emulate unrestricted MAC addresses

Error Codes
Since it is much easier to work with: B 5 A 4 1 A F C rather than: 1 0 1 1 | 1 0 0 1 | 1 0 1 0 | 0 1 0 0 | 0 0 0 1 | 1 0 1 0 |
1 1 1 1 | 1 1 0 0 hexadecimal is often used when developing new software or when trying to trace errors in
programs.

 The contents of part of the computer memory can hold the key to help solve many problems.
 When the memory contents are output to a printer or monitor, this is known as a MEMORY DUMP:
 These numbers refer to the memory location of the error and are usually automatically generated by the
computer.

HTML Colours
 Every pixel in a computer colour monitor may have only one colour at any moment
 Each colour is made up of a combination of shades of red, green and blue
 Each pixel stores information about its state and colour in a memory location.
 hexadecimal RGB colour values that specify the amount of Red, Green and Blue light that need to appear at
a pixel, in order to produce a specific colour
 Each colour value is represented as a hexadecimal value of two digits that may take up values from 00 to FF

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.
 An IPv6 address is a 128-bit number broken down into 16-bit chunks, represented by a hexadecimal number.
 Note IPv6 uses a colon (:) rather than a decimal point (.) as used in IPv4

ASCII and Unicode


 The American Standard Code for Information Interchange (ASCII) is a character-encoding scheme originally
based on the English alphabet.
 To do that a number is assigned to each letter from 0 to 127 in denary or 0 to 7F in hexadecimal.
 Together with 32 control codes (that use codes O to 31 (denary) or 00 to 19 (hexadecimal))
 For example: letter K is assigned the number 75.
 ASCII uses 7 bits to represent each character which means that it can achieve 27 = 128 different
representations.
 Extended ASCII uses 8-bit codes (0 to 255 in denary or Oto FF in hexadecimal).
 The main disadvantage is that it does not represent characters in non-Western languages, for example
Chinese characters.
 For this reason, different methods of coding have been developed over the years. One coding system is
called Unicode.
 Unicode can represent all languages of the world, thus supporting many operating systems, search engines
and internet browsers used globally.
 ASCII uses one byte to represent a character, whereas Unicode will support up to four bytes per character.
File Compression
Can be lossless or lossy

Uses a compression algorithm

Advantages when transferring

 Smaller file to transmit


 File transmitted quicker
 Uses less bandwidth

Lossless e.g. RLE, Text Document, Program

 Code must be exactly the same as the original


 If not the same as original file will not work
 A (compression) algorithm is used
 No data is removed in the process
 Used for Programs & Text Files
 Repeated words (are identified) and are replaced by an index
 The number of times the word appears is stored

Lossy e.g. Video file (Mpeg)

 Makes the file smaller than lossless


 Quality can be reduced but the file will still run
 Redundant data can be removed
 Used when no requirement for file to be exactly same as original

Compressing text files

 Use lossless
 Repeated words can be indexed
 Repeated words sections e.g. ‘ou’ can be replaced with numerical value
 Can be saved a s a zip file

File Formats
MIDI

 Musical Instrument Digital Interface


 Standard adopted by the music industry for controlling devices such as synthesizers and sound cards and
electronic instruments.
 Stores commands on how to play sounds – NOT SOUNDS
 Specifies
o Note
o Duration
o Volume
o Instrument

Mp3

 File compression system for music which does not noticeably affect the quality of the sound
 Removes sound humans can’t hear well
 If two sounds playing at the same time the softer sound is removed
 Uses perceptual music shaping
Differences between MP3 and MIDI

 MP3 a digital recording of sound


 Mp3 produced by recording software
 Mp3 a compressed file format
 MIDI Instructions of how to make sound
 MIDI Non-audio recording
 MIDI File created using digital musical instruments
 MIDI Produced by synthesizer

Mp4

 MPEG-4 (MP4) files are slightly different to MP3 files. This format allows the storage of multimedia files
rather than just sound.
 Music, videos, photos and animation can all be stored in the MP4 format.

Jpeg

 As with MP3 format, once the image is subjected to the jpeg compression algorithm, a new file is formed
and the original file can no longer be constructed.
 Jpeg will reduce the RAW BITMAP image by a factor of between 5 and 15 depending on the quality of the
original.
 Jpeg relies on certain properties of the human eye and, up to a point, a certain amount of file compression
can take place without any real loss of quality.
 Some computer imaging software boasts that it can produce over 40 million different colours – the human
eye is only able to differentiate about 10 million colours.
 by separating pixel colour from brightness, images can be split into 8 x 8 pixel blocks, for example, which
then allows certain 'information' to be discarded from the image without causing any real noticeable
deterioration in quality.

Image Capture

 Image converted from analogue to digital (ADC)


 Image turned into pixels
 Each pixel given binary value
 Each pixel given a colour
 Pixels form a grid
 Pixels stored in sequence

Image Resolution

 Resolution measures the number of pixels in a digital image or display. It is defined as width by height.
 For example, the resolution of an HDTV is 1920 x 1080.
 A digital photo that is 3,088 pixels wide by 2,320 pixels tall has a resolution of 3088 × 2320. Multiplying these
numbers together produces 7,164,160 total pixels. Since the photo contains just over seven million pixels, it
is considered a "7 megapixel" image.
 The file size of an image is determined by the number of pixels.
 In a 3-megapixel image would be 3 megapixels × 3 colours. In other words, 9 megabytes (each pixel occupies
3 bytes because it is made up of the three main colours: red, green and blue).

Colour Depth

 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 6 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.
Sound Capture

 Each sound wave has a frequency, wavelength and amplitude. The amplitude specifies the loudness of the
sound.
 the amplitude of the sound wave is first determined at set time intervals (the sampling rate)
 each sample of the sound wave is then encoded as a series of binary digits.

Increasing the number of possible values used to represent sound amplitude also increases the accuracy of
the sampled sound

Sampling

 The number of bits per sample is known as the sampling resolution (also known as the bit depth).
 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’.
 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.

Run-length encoding
 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.

Using RLE on text data

Consider the following text string: 'aaaaabbbbccddddd'. Assuming each character requires 1 byte then this
string needs 16 bytes. If we assume ASCII code is being used, then the string can be coded as follows:

This means we have five characters with ASCII code 97, four characters with ASCII code 98, two characters
with ASCII code 99 and five characters with ASCII code 100.

Assuming each number in the second row requires 1 byte of memory, the RLE code will need 8 bytes. This is
half the original file size.
Using RLE Flags

One issue occurs with a string such as 'cdcdcdcdcd' where RLE compression isn't very effective.

To cope with this, we use a flag. A flag preceding data indicates that what follows are the number of
repeating units (for example, 255 05 97 where 255 is the flag and the other two numbers indicate that there
are five items with ASCII code 97).

When a flag is not used, the next byte(s) are taken with their face value and a run of 1 (for example, 01 99
means one character with ASCII code 99 follows).

Using RLE on text data (Example)

The original string contains 32 characters and would occupy 32 bytes of storage.

The coded version contains 18 values and would require 18 bytes of storage.

Introducing a flag (255 in this case) produces:

This has 15 values and would, therefore, require 15 bytes of storage. This is a reduction in file size of about
53% when compared to the original string.

Using RLE on a B&W image (Example)

The letter ‘F’ in a grid where each square requires 1 byte of storage. A white square has a value 1 and a black
square a value of 0:

The 8 x 8 grid would need 64 bytes; the compressed RLE format has 30 values, and therefore needs only 30
bytes to store the image.

Using RLE on a colour image (Example)

An object in four colours. Each colour is made up of red, green and blue (RGB] according to the code on the
right.

This produces the following data: 2 0 0 0 4 0 255 0 3 0 0 0 6 255 255 255 1 0 0 0 2 0 255 0 4 255 0 0 4 0 255 0
1 255 255 255 2 255 0 0 1 255 255 255 4 0 255 0 4 255 0 0 4 0 255 0 4 255 255 255 2 0 255 0 1 0 0 0 2 255
255 255 2 255 0 0 2 255 255 255 3 0 0 0 4 0 255 0 2 0 0 0.

The original image (8 x 8 square) would need 3 bytes per square (to include all three RGB values). Therefore,
the uncompressed file for this image is 8 x x = 192 bytes.
The RLE code has 92 values, which means the compressed file will be 92 bytes in size. This gives a file
reduction of about 52%.

Calculating file sizes - Example


A photograph is 1024 x 1080 pixels and uses a colour depth of 32 bits. How many photographs of this size would fit
onto a memory stick of 64GiB?

Multiply number of pixels in vertical and horizontal directions to find total number of pixels = (1024 x 1080) =
1 105 9 20 pixels

Now multiply number of pixels by colour depth then divide by 8 to give the number of bytes= 1105920 x 32 =
35389 440/8 bytes= 4423680 bytes

64GiB=64x 1024x 1024x 1024=68719476736 bytes

Finally divide the memory stick size by the files size 68719476736 = 15 534 photos.

…………………………………………………………………………………………………………………………………………………………

You might also like