0% found this document useful (0 votes)
5 views18 pages

Chapter 1

The document discusses data representation in computing, focusing on binary, hexadecimal, and ASCII systems. It explains how to convert between denary and binary numbers, the uses of hexadecimal in color references and MAC addresses, and the concept of Binary Coded Decimal (BCD). Additionally, it covers image representation through bitmap and vector images, detailing their characteristics and implications for storage and quality.

Uploaded by

Saaren Sawmy
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)
5 views18 pages

Chapter 1

The document discusses data representation in computing, focusing on binary, hexadecimal, and ASCII systems. It explains how to convert between denary and binary numbers, the uses of hexadecimal in color references and MAC addresses, and the concept of Binary Coded Decimal (BCD). Additionally, it covers image representation through bitmap and vector images, detailing their characteristics and implications for storage and quality.

Uploaded by

Saaren Sawmy
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/ 18

Chapter 1: Information Representation

1.1 Data representation

Binary Number System

In our normal everyday life we use the decimal number system which is a base-10 number
system. The numbers in the decimal number system are called denary numbers. A binary
number system, on the other hand, is a base-2 number system. This system uses only 0s
and 1s to represent letters, numbers and other characters and it is used by modern
computers. Computers make use of electronic circuits which use electricity. Electricity has
two possible states either ON or OFF. Hence, the binary number system is an ideal method
of representing the state of circuits since it uses a combination of zero and one only. The
binary digits 0 and 1 are known as binary bits.

Turning a denary number into binary

To turn a denary number into a binary number simply put the column headings, start at the left hand
side and follow the steps:

 If the column heading is less than the number, put a 1 in the column and then subtract the
column heading from the number. Then start again with the next column on the right.
 If the column heading is greater than the number, put a 0 in the column and start again with the
next column on the right.
Note: You will be expected to be able to do this with numbers up to 255, because that is the biggest
number that can be stored in one byte of eight bits.

e.g. Change 117 (in denary) into a binary number.

Answer: Always use the column headings for a byte (8 bits)

128 64 32 16 8 4 2 1

Follow the algorithm.

128 is greater than 117 so put a 0 and repeat.

128 64 32 16 8 4 2 1
0
64 is less than 117 so put a 1.

128 64 32 16 8 4 2 1
0 1
Take 64 from 117 = 53, and repeat.

32 is less than 53, so put a 1.

1
128 64 32 16 8 4 2 1
0 1 1
Take 32 from 53 = 21, and repeat.

If you continue this the result (try it) is

128 64 32 16 8 4 2 1
0 1 1 1 0 1 0 1
So 117 (in denary) = 01110101 (in binary).

Turning a binary number into denary

To turn a binary number into denary, simply put the column headings above the binary number and
add up all the columns with a 1 in them.

e.g. Change 10110110 into denary.

Answer:

128 64 32 16 8 4 2 1
1 0 1 1 0 1 1 0
So 10110110 = 128 + 32 + 16 + 4 + 2 = 182 (in denary).

Hexadecimal Number System

256 16 1

So 117 (in denary) is 7 lots of 16 (112) plus an extra 5. Fitting this in the columns gives

256 16 1
0 7 5

2
Practice Exercises
1. Convert the following denary numbers into binary.
5, 12, 25, 119, 125
2. Convert the following binary numbers into denary.
10
111
10101
11110
10001111

3. Convert the following denary numbers into hexadecimal

48, 138, 193, 215, 232

4. Convert the following binary numbers into hexadecimal


10
111
10101
11110
10001111

Uses of hexadecimal numbers


(a) Colour References
Hexadecimal numbers are use for colour references due to the large amount of colour
possibilities available. In HTM colour references are expressed using six hexadecimal digits
(two each for the red, green and blue components in that order).
Example of a sample HTML code

code: <font color="red">this is red</font>

output on screen: this is red

You could also use the hexadecimal code for red, which is #FF0000.

code: <font color="#FF0000">this is red</font>

output on screen: this is red

3
A sample screenshot of Ms Visual Basic interface

Colour reference in hexadecimal

(b) Media Access Control (MAC) Addresses


A MAC address is a unique identifier assigned to network interfaces for communications on
the network. It is a hardware address/physical address that uniquely identifies
each node/device of a network.The MAC address is rarely changed so that a particular
device can always be identified no matter where it is.
An example of a MAC address is 00:A0:C9:14:C8:29

A MAC address is usually made up of 48 bits which are shown as six groups of hexadecimal
digits (although 64-bit addresses are also known):
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.

4
(c) Assembly Language
Hexadecimal in assembly language coding is used instead of binary to make it much simpler
for humans to write codes.

(d) Machine Code


This is the language that the computer understands directly since it is in binary form (0’s and
1’s). These binary digits are often converted both from and to hexadecimal for human
viewing and modification.
(e) Memory Dumps
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 sove many
problems. When the memory contents are output to a printer or monitor, this is known as
memory dump. A programmer can look at each of the hexadecimal code and determine
where the error lies.

5
Binary Coded Decimal
Some numbers are not proper numbers because they don’t behave like numbers. A barcode for
chocolate looks like a number, and a barcode for sponge cake looks like a number, but if the
barcodes are added together the result is not the barcode for chocolate cake. The arithmetic does
not give a sensible answer. Values like this that look like numbers but do not behave like them are
often stored in binary coded decimal (BCD). Each digit is simply changed into a four bit binary
number which are then placed after one another in order.

e.g. 398602 in BCD

Answer: 3 = 0011 9 = 1001

8 = 1000 6 = 0110

0 = 0000 2 = 0010

So 398602 = 001110011000011000000010 (in BCD)

Uses of BCD

 Representation of digits in a calculator


 Representation of digits in a clock display

Each denary digit will have a BCD equivalent value which makes it easy to convert from computer
output to denary display.

One’s and Two’s Complement for negative numbers


1’s complement of a binary number is another binary number obtained by toggling all
bits in it, i.e., transforming the 0 bit to 1 and the 1 bit to 0.

1's complement of "0111" is "1000"


1's complement of "1100" is "0011"

2’s complement of a binary number is 1 added to the 1’s complement of


the binary number.
Examples:
2's complement of "0111" is "1001"

2's complement of "1100" is "0100"

6
Binary Addition
The binary number system uses only two digits 0 and 1 due to which their
addition is simple. There are four basic operations for binary addition, as
mentioned above.

0+0=0
0+1=1
1+0=1
1+1=10
The above first three equations are very identical to the binary digit number.
The column by column addition of binary is applied below in details. Let us
consider the addition of 11101 and 11011.

Binary Subtraction

First, confirm that the digits in the subtrahend and minuends


should be equal. In the above example, the digits in the minuends
have 7 whereas in subtrahend the digits are 5. So we need to
extend the digits in subtrahend by adding zeros. A 2’s
complement of a number can be achieved by complementing
each digit of the number like zero’s to ones and ones to zeros.
Finally, add one to one’s complement. An example of this two’s
complement is shown below.

0011011
1’s complement can be achieved by converting 0’s to 1’s and 1’s
to 0’s. So the result will be like the following.

0011011 – – – -> 1100100 (1’s complement)


2’s complement can be achieved by adding 1 to 1’s complement.
So the result will be like the following.
7
1100100
+ 0000001
_________
= 1100101
Now add the subtrahend‘s 2’s complement & minuend.

1101101 (subtrahend)
+ 1100101 (2’s complement)
________
(MSB) (1)1010010

Practice Exercises
Perform the following binary addtion

8
Perform the following binary subtraction

Check your answers on


https://www.cimt.org.uk/projects/mepres/book9/bk9i1/bk9_1i2.html

Overflow
In computing, an overflow error can occur when a calculation is run but the computer is
unable to store the answer correctly. All computers have a predefined range of values they
can represent or store. Overflow errors occur when the execution of a set of instructions
return a value outside of this range.

Representing Character Data


1. ASCII (American Standard Code for Information Interchange)

It is a code for representing 128 English characters as numbers, with each


letter assigned a number from 0 to 127. For example, the ASCII code for
uppercase M is 77. Most computers use ASCII codes to represent text, which
makes it possible to transfer data from one computer to another.

2. Extended ASCII

This is a set of codes that extends the basic ASCII set. The basic ASCII set uses 7
bits for each character, giving it a total of 128 unique symbols. The extended ASCII
character set uses 8 bits, which gives it an additional 128 characters.

9
3. Unicode
Unicode is a universal character encoding standard. It defines the way individual
characters are represented in text files, web pages, and other types of
documents.
Unlike ASCII, which was designed to represent only basic English characters,
Unicode was designed to support characters from all languages around the
world. The standard ASCII character set only supports 128 characters, while
Unicode can support roughly 1,000,000 characters. While ASCII only uses one
byte to represent each character, Unicode supports up to 4 bytes for each
character.

Difference the various unit of measurement for computer storage

Work out the conversion for tebi and tera.

10
Image representation
Bitmap Images
Bitmap images (also known as raster images) are made up of pixels on a grid. Pixels are
picture elements, i.e tiny dot of individual colour that makes up what you see on your screen.
The dots come together to form the image. Most computer monitors display approximately
70-100 pixels per inch.
Bitmap images are resolution dependent. Resolution is the number of pixels in an image and
it is usually stated as dpi (dots per inch) or ppi (pixels per inch)
Because bitmap images are resolution dependent, it is difficult to increase or decrease their
size without sacrificing a degree of image quality. When the size of a bitmap image is
reduced, we need to “throw away pixels” whereas when the image size is increased, we
need create new pixels. A special software is used for resizing images.

Vector images
Vector images are made up of many individual, scalable objects. These objects are defined
by mathematical equations rather than pixels, so they always render at the highest quality.
Objects may consist of lines, curves and shapes with editable attributes such as colour, fill
and outline. Changing the attributes of a vector object does not affect the objects itself.
Because they are scalable, vector-based images are resolution independent. You can
increase and decrease the size of vector images to any degree. Another advantage of vector
images is that they are not restricted to rectangular shape like bitmaps.
The primary disadvantage of vector images is that they are unsuitable for producing photo-
realistic imagery. Vector images are usually made up of solid areas of colour or gradients,
but they cannot depict the continuous subtle tones of a photograph. That’s why most of the
vector images you see tend to have a cartoon-like appearance.
Vector images primarily originate from software. You can’t scan an image and save it as a
vector file without using special conversion software. On the other hand, vector images can,
quite easily, be converted to bitmaps. This process is called rasterizing.

When storing images as pixels, we have to consider:


 At least 8 bits (1 byte) per pixel are needed to code a coloured image (this gives 256
possible colours by varying the intensity of the blue , green and red elements).
 True colour requires 3 bytes per pixel (24 bits), which gives more than one million
colours.
 The number of bits used to represent a pixel is called colour depth.

Image resolution refers to the number of pixels that make up an image ; for example, an
image could contain 4096 x 3192 pixels (12738656 pixels in total). In short, how many pixels
make up an image.
Screen resolution refers to the number of horizontal pixels and the number of vertical pixels
that make up a screen display ( for example , if the screen resolution is smaller than the

11
image resolution then the whole image cannot be shown on the screen or the original
image will now be a lower quality).

When enlarging an image, the number of pixels that makes up the image remains the same
but the area covered is now increased. This means that some sharpness could be lost,
which is known as the Pixel density.

The first image is the original By the time it has been scaled up to make the last image, it
has become ‘fuzzy”. This is so because the first and last image have different pixel
densities.

The main disadvantage of using high resolution images is the increase in file size. As the
number of pixels representing an image is increased, the file size also increases. This
determines how many images can be stored on , for example, a hard drive. It also has an
impact on the time downloading an image from the internet .

Bitmap file header


It is a block of bytes at the start of the file used to identify it. The application reads this block
first to ensure that the file is actually a bitmap file and that it is not damaged.
number of pixels row * no of pixels column

Colour depth
It is the number of bits used to represent the colour of a single pixel, e.g a colour depth of
one bit gives a monochrome (black and white) image, and the number of colours per pixel is
21 which equals to two colours.
A colour depth of 2 bits gives 22= 4 colours per pixel.
Colour depth can also be 4 bits, 8 bits or 24 bits.

12
Calculating file size for different colours
Assume there is an image ofresolution
300x225 = 62500 pixels
If the image uses 1 bit to store the colour for each pixel, then the image size would be:
no of pixels * colour depth = image size

13
67500 * 1 = 67500 bits
67500/8 bytes = 67500 / (8*1024) KB
If the image uses 2 bits to store the colour of each pixel.
Image size = 67500 * 2 = 135000 bits

Vector representation of images


Vector graphics are images defined using mathematics and geometry such as points, lines, curves and
shapes or polygons. They allow for scale ability. Objects and properties are stored mathematically.
A drawing list is a set of commands used to define a vector image.
Commands to define rectangle, line and circle are
<rect…./>,
<line…./>,
<circle…./> respectively
Each of these objects has properties to tell you the size, color, position, etc…

E.g 1) Rectangle
(x,y)

x and y starting coordinates given at top left


Drawing list for rectangle.
<rect x = “14”y = “23”
Width = “250”height = “50”
fill = “red”
stroke = “black” stroke width = “1” />
border width of border

drawing list for a circle cx ,cy) centre coordinates r = radius


<circle cx = “100” cy = “100” r = “50”
fill = “red”
stroke = “black” stroke width = “5”/>

red

Un Texte
blue
14
green
<rect
Width = “100” height = “80”
x = “0” y =”70”
fill = “green” />

<line
x = “5” y = “5”
x2 = “250” y2 = “95”
stroke = “red” />
<circle
Cx = “90” cy = “80” r = “50”
Fill = “blue” />
<text x=”180’ y = “60”
Un Texte
</text>

NOTE: Circle is on top because it is drawn last.


To leave out an edge stroke don’t put the stroke command
Comparison between vector and bitmap
 A bitmap image is composed of a fixed set of dots (pixels) while the vector image is
composed of a fixed set of shapes.
 Scaling the bitmap reveals the pixels and scaling the vector image preserves the
shapes.
 Vector images scale without file size increase or decrease. Bitmap images scale
resulting in file size increase or decrease.
 Vector images scale without distortion to the image. Bitmap images distort when
scaling (pixelate)
 Bitmaps are better for photo editing and they require less processing power to
display.

15
Comparison between Vector graphics and bit-map images

Vector graphic images Bit-map images


Made up of geometric shapes which require Made up of tiny pixels of different colours
definition /attributes
To edit the design, it is necessary to Possible to edit each of the pixels to
change each of the geometric shapes change the design of the image
Do not require large file size since it is File size is large because of the use of
made up of simple geometric shapes pixels (which give very accurate designs)
Vector graphics are not usually very The final image is usually very realistic
realistic because the number of geometric since other images are built up pixel by
shapes is limited. pixel .
File formats are usually in .svg, .cgm, .odg File formats are usually in .jpeg, .bmp, .png

Sound representation
Sound is an analogue wave-form of different volumes and itches (larger energy waves give a
louder sound).
How is sound stored in computers?
Sound waves in nature are continuous. It is therefore difficult to record sound perfectly as
computers can only store discreet data, i.e. data that has a limited number of data points.
Recording sound clip using sampling involves the following:
1. Amplitude of sound wave is first determined at set time intervals (sampling rate)
2. Gives an approximate representation of sound wave
3. Sound wave is then encoded as as series of binary digits
Sampling rate - It is the number of samples taken in one second.
Hertz - It is the S.I unit of frequency defined as the number of cycles per second.
Sampling resolution - It is the number of bits assigned to each sample. The sampling
resolution allows us to set the range of volumes that can be stored for each sample. If you
have a low sampling resolution, then the range of volumes will be very limited. And if you
have a high sampling resolution, then file size may become unfeasible.

Advantages of a higher sampling rate or larger resolution


 Better sound quality
 Less sound distortion
Disadvantages of a higher sampling rate or larger resolution
 Larger file size

16
 Longer download time
 Greater processing power
File size = sample rate x sample resolution x length of sound
Quest :For the following sound sample work out its size:
Sample rate = 1600Hz, Sample resolution = 8 bits, Length of sound = 10s
File size = 1600 x 8 x 10
= 1280000 bits

The features of a sound editing software include:

 Sound editing functions include cut, copy, paste, delete, insert,


 Audio effects include amplify, echo, reverse and many more
 Mix various sound tracks
 Convert between different audio formats

Principles of File Compression


File is compressed for the following reasons:
 To reduce file size and thus save disk space
 To allow faster upload and download of files on networks

There are two types of file compression:


Lossy Compression
Here some details are lost during compression. For example, the picture of a person can be
compressed using the lossy technique and then sent as an email attachment to a friend.
Lossless Compression
Here no details are lost during compression. For example, the X-ray photograph of a patient
is compressed using the lossless technique.
Here the decompressed image and the original one are the same.

17
Run Length Encoding

Run-length encoding (RLE) is a very simple form of data compression in which runs of
data (that is, sequences in which the same data value occurs in many consecutive data
elements) are stored as a single data value and count, rather than as the original run. This is
most useful on data that contains many such runs: for example, relatively simple graphic
images such as icons, line drawings, and animations. It is not useful with files that don't have
many runs as it could potentially double the file size.

Example

For example, consider a screen containing plain black text on a solid white background.
There will be many long runs of white pixels in the blank space, and many short runs of
black pixels within the text. Let us take a hypothetical single scan line, with B representing a
black pixel and W representing white:

WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWW
WWWWWWWWBWWWWWWWWWWWWWW

If we apply the run-length encoding (RLE) data compression algorithm to the above
hypothetical scan line, we get the following:

Interpret this as twelve W's, one B, twelve W's, three B's, etc.

18

You might also like