Computer Science
Computer Science
1=TRUE,ON,YES 0=FALSE,OFF,NO
One binary number is called a bit
How to change binary to our number system ?
Each time a 1-value appears in a binary number column , the column
value(heading)is added to the total .
Example :
128 64 32 16 8 4 2 1
Because it a number based on 16 different digits it contains the numbers 0-9 and
A=10, b=11, c=12, d=13, e=14, f=15
:Converting binary to hexadecimal
Converting from binary to hexadecimal is a fairly
easy process. Starting from the right and moving
left, split the binary number into groups of 4 bits. If
the last group has less than 4 bits, then simply fill in
with 0s from the left. Take each group of 4 bits and
convert it into the equivalent hexadecimal digit
:Example
1.1.3 use of hexadecimal system
As we have seen, a computer can only work with binary data. Whilst computer scientists can work with
binary, they find hexadecimal to be more convenient
to use. This is because one hex digit represents four binary digits. 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
» error codes
» MAC addresses
» IPv6 addresses
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) 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
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
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
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.
1.1.4 addition in binary numbers
If the number (answer) is more than 8-bits it is considered 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.
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).
Example :
Example:
Convert −79 into an 8-bit binary number using two’s complement format.
1.2text sound and images
1.2.1 character sets-ASCII code and Unicode
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 (0 to 127 in denary or 00 to 7F in
hexadecimal) that 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)).
1.1.2 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.
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
1Hz means ‘one sample per second’.
» 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.
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.
CDs have a 16-bit sampling resolution and a 44.1 kHz sample rate – that is 44 100 samples every second.
This gives high-quality sound reproduction.
» 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 (2 2 = 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 (2 3 = 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
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 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.
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.
This system is more accurate. Internal memories (such as RAM and ROM) should be measured using the
IEC system.
Example:
Example:
1.3.3 data compression
The calculations in Section 1.3.2 show that 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 bits per second. 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.
With this technique, the file compression algorithm eliminates unnecessary data from the file. This
means the original file cannot be reconstructed once it has been compressed.
» a sound file, it may reduce the sampling rate and/or the resolution.
Lossy files are smaller than lossless files which is of great benefit when considering storage and data
transfer rate requirements.
» JPEG.
MP3 files are used for playing music on computers or mobile phones. This compression technology will
reduce the size of a normal music file by about 90%.
But 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:
» 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.
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 When a camera takes a photograph, it produces a raw bitmap file which can be very large in size.
These files are temporary in nature. JPEG is a lossy file compression algorithm used for bitmap images
» 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
With this technique, all the data from the original uncompressed file can be reconstructed. This is
particularly important for files where any loss of data would be disastrous
Lossless file compression is designed so that none of the original detail from the file is lost.
Run-length encoding (RLE) can be used for lossless compression of a number of different file formats:
– the first value represents the number of identical data items in the run
– the second value represents the code of the data item (such as ASCII code if it is a keyboard character)
Using RLE on text data Consider the following text string: ‘aaaaabbbbccddddd’. Assuming each character
requires 1byte then this string needs 16bytes. 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.
Example black and white image:
The packets of data are usually quite small, typically 64KiB.The idea of splitting up data in this way
means each packet can be sent along a different route to its destination. This would clearly be of great
benefit if a particular transmission route was out of action or very busy. The only drawback of splitting
data into packets is the need to reassemble the data when it reaches its destination.
Packet structure
» a packet header
» the payload
» a trailer.
For each packet, the packet header consists of:
» packet size
the header often also contains another value indicating how many packets there are in total for this
transmission.
» some way of identifying the end of the packet; this is essential to allow each packet to be separated
from each other as they travel from sending to receiving station
» an error checking method; cyclic redundancy checks (CRCs) are used to check data packets:
– this involves the sending computer adding up all the 1-bits in the payload and storing this as a hex
value in the trailer before it is sent
– once the packet arrives, the receiving computer recalculates the number of 1-bits in the payload
– the computer then checks this value against the one sent in the trailer
– if the two values match, then no transmission errors have occurred; otherwise the packet needs to be
re-sent.
router – a device that enables data packets to be moved between different networks, for example to
join a LAN to a WAN
Packet switching is a method of data transmission in which a message is broken up into a number of
packets. Each packet can then be sent independently from start point to end point.
node – stages in a network that can receive and transmit data packets; routers are nodes in
communication networks
» the method is more prone to errors with real-time streaming (for example, a live sporting event being
transmitted over the internet)
» there is a delay at the destination whilst the packets are being re-ordered.
Sometimes it is possible for packets to get lost because they keep ‘bouncing’ around from router to
router and never actually reach their destination. Eventually the network would just grind to a halt as
the number of lost packets mount up, clogging up the system. To overcome this, a method called
hopping is used. A hop number is added to the header of each packet
Each packet has a maximum hop number to start with. Once a hop number reaches zero, and the packet
hasn’t reached its destination, then the packet is deleted when it reaches the next router. The missing
packets will then be flagged by the receiving computer and a request to re-send these packets will be
made.
Simplex mode occurs when data can be sent in ONE DIRECTION ONLY
Half-duplex mode occurs when data is sent in BOTH DIRECTIONS but NOT AT THE SAME TIME
Full-duplex mode occurs when data can be sent in BOTH DIRECTIONS AT THE SAME TIME
Serial data transmission occurs when data is sent ONE BIT AT A TIME over a SINGLE WIRE/CHANNEL.
Parallel data transmission occurs when SEVERAL BITS OF DATA (usually one byte) are sent down
SEVERAL CHANNELS/WIRES all at the same time.
» interference (all types of cable can suffer from electrical interference, which can cause data to be
corrupted or even lost)
» problems during packet switching (this can lead to data loss – or it is even possible to gain data!)
» skewing of data (this occurs during parallel data transmission and can cause data corruption if the bits
arrive out of synchronisation).
» parity checks
» checksum
» echo check.
One of the bits in the byte (usually the most significant bit or left-most bit) is reserved for a parity bit.
The parity bit is set according to whether the parity being used is even or odd.
A checksum is a method used to check if data has been changed or corrupted following data
transmission. Data is sent in blocks, and an additional value, called the checksum, is sent at the end of
the block of data.
» when a block of data is about to be transmitted, the checksum is calculated from the block of data
» the calculation is done using an agreed algorithm (this algorithm has been agreed by sender and
receiver)
» at the receiving end, the checksum is recalculated by the computer using the block of data (the
agreed algorithm is used to find the checksum)
» the re-calculated checksum is then compared to the checksum sent with the data block
» if the two checksums are the same, then no transmission errors have occurred; otherwise a request is
made to re-send the block of data.
With echo check, when data is sent to another device, this data is sent back again to the sender. The
sender’s computer compares the two sets of data to check if any errors occurred during the
transmission process.
» the returned data is compared with the original data by the sender’s computer
» if there are no differences, then the data was sent without error
» if the two sets of data are different, then an error occurred at some stage during the data
transmission.
Check digits are used to identify errors in data entry caused by mis-typing or mis-scanning a barcode.
They can usually detect the following types of error:
» transposition errors where two numbers have changed order, for example 5037 instead of 5307
» omitted or extra digits, for example 537 instead of 5307 or 53107 instead of 5307
» ISBN 13
» Modulo-11
the receiving device receives an error detection code as part of the data transmission »
however, if an error is detected, the receiving device now sends a negative acknowledgement to the »
sending device and requests re-transmission of the data
and if no acknowledgement of any type has been received by the sending device within this time ...»
.… limit, it automatically re-sends the data until a positive acknowledgement is received
.………………00
Symmetric and asymmetric encryption 2.3
The purpose of encryption 2.3.1
When data is transmitted over any public network (wired or wireless), there is always a risk of it being
.intercepted, using encryption helps to minimize this risk
The original data being sent is know as plaintext. Once it has gone through an encryption algorithm, it
:produces ciphertext
Asymmetric encryption
Asymmetric encryption was developed to overcome the security problems associated with symmetric
:encryption. It makes use of two keys called the public key and the private key