Number Representation
Number Representation
Number Representation
128 64 32 16 8 4 2 1
Converting from denary to binary (Method 2)
1 Kilobyte (1Kb) 103 1000 Bytes 1 Kibibyte (1Kb) 210 1024 bytes
1 Megabyte (1Mb) 106 1000000 Bytes 1 Mebibyte 220 1,048,576
1 Gigabyte (1Gb) 109 1 000 000 000 1 Gibibyte 230 1 073 741 824
bytes bytes
1 Terabyte (1Tb) 1012 1 000 000 000 1 Tebibyte (1Tb) 240 1 099 511 627
000 bytes 776 bytes
1 Petabyte (1Pb) 1015 100 000 000 1 Pebibyte (1Pb) 250 125 899 906
000 000 bytes 842 624 bytes
1 exabyte (1Eb) 1018 1 exbibyte (1Eb) 260
Octal Number system
The octal number system is no longer in use. It is also
known as base 8 and its digits run from 0,1,2..7
FC is the amount of red, 23 is the amount of green and 8A is the amount of blue in the colour.
(i) Convert the hexadecimal code FC into denary.
...................................................................................................................................[1]
(ii) The amount of green in binary is 00100011. This has the denary number 15 added to it to create
a second colour.
Add the denary number 15 to the binary number 00100011 and give your answer in
binary.
Two’s complement
The binary number obtained if 1 is added to the one's complement
number.
For a quicker method to convert to two’s complement you start at the least
significant bit and move left ignoring any zeros up to the first 1 which is also ignored.
Any remaining bits are then changed from Oto 1 or from 1 to 0.
Sign and magnitude vs two’s complement
one’s and two’s complement
• sign and magnitude representation has a positive and a negative zero
which could cause a problem if comparing values.
• there is an extra negative value represented in two's complement.
• representations in two's complement are such that starting from the
lowest negative value each successive higher value is obtained by
adding 1 to t he binary code. In particular, when all digits are 1 the
next step is to roll over to an all-zero code. This is the same as any
digital display would do when each digit has reached its maximum
value.
Converting two’s complement to denary
Convert 10010110 in two’s complement to denary
= -106
OR
Convert 10010110 in two’s complement to denary
Assign each digit its place value keeping in mind that the most
significant bit is negative
-1X128+ 0x64 + 0x32 + 1x16 + 0x8 + 1x4 +1x2 + 0x1
= -128 +16 + 4 +2
= -106
Qs
Using two’s complement, show how the following denary numbers could
be stored in an 8-bit register:
(i) 114
(ii) -93
(iii) 124
(iv) -77
Binary coded decimal (BCD)
If there is an application where single denary digits are required to be
stored or transmitted, BCD offers an efficient solution. The BCD code
uses four bits (a nibble) to represent a denary digit.
There are, however, two options for BCD; the first is to store one BCD code in one
byte leaving four bits unused. The other option is packed BCD where two 4-bit
codes are stored in one byte.
Example
BCD applications
• on the screen of a calculator or in a digital time display.
• representation of currency values.
Assignment
Read on internal coding of text ASCII and Unicode
Next up
1.05 Images
Qs
Thank you for covering internal coding of text ASCII and
Unicode
Test 1
Images
There are various sources of images. An image can be created by
using an appropriate graphics package (name graphic creation
packages you are familiar with). Alternatively, when an image already
exists independently of the computer system, the image can be
captured by using photography or by scanning.
There are two main forms for storing images, namely vector graphics
and bitmap images.
Images
There are various sources of images. An image can be created by
using an appropriate graphics package (name graphic creation
packages you are familiar with). Alternatively, when an image already
exists independently of the computer system, the image can be
captured by using photography or by scanning.
There are two main forms for storing images, namely vector graphics
and bitmap images.
Vector graphic
A vector graphic file contains a drawing list. The list contains a command for
each object included in the image.
Each command has a list of attributes, each attribute defines a property of the
object. The properties include the basic geometric data such as, for a circle, the
position of the centre and its radius. In addition, properties are defined such as
the thickness and style of a line, the colour of a line and the colour that fills the
shape.
Vector graphic
Whenever the image is to be displayed the file is read, the appropriate
calculations are made and the objects are drawn to a suitable scale. If the user
then requests that the image is redrawn at a larger scale the file is read again
and another set of calculations are made before the image is displayed. This
avoids image distortion, such as the image appearing squashed or stretched.
Note that a vector graphic file can only be displayed directly on a graph plotter,
which is an expensive specialised piece of hardware. For the image to appear
correctly on other types of display, the vector graphic file oft en has to be
converted to a bitmap.
Bitmaps
The fundamental concept underlying the creation of a bitmap file is that the picture
element (pixel) is the smallest identifiable component of a bitmap image. The image is
stored as a two-dimensional matrix of pixels. The pixel itself is a very simple construct; it has
a position in the matrix and it has a colour. It does not matter whether each pixel is a small
rectangle, a small circle or a dot.
The scheme used to represent the colour has to be defined. The simplest option is to use
one bit to represent the colour, so that the pixel is either black or white. Storage of the colour
in four bits allows simple greyscale colouring. At least eight bits per pixel are necessary to
provide a suff icient range of colours to provide a reasonably realistic representation of any
image. The number of bits per pixel is sometimes referred to as the colour depth.
Working space
1
Vector graphics
The fundamental concept underlying the creation of a bitmap file is that the picture
element (pixel) is the smallest identifiable component of a bitmap image. The image is
stored as a two-dimensional matrix of pixels. The pixel itself is a very simple construct; it has
a position in the matrix and it has a colour. It does not matter whether each pixel is a small
rectangle, a small circle or a dot.
The scheme used to represent the colour has to be defined. The simplest option is to use
one bit to represent the colour, so that the pixel is either black or white. Storage of the colour
in four bits allows simple greyscale colouring. At least eight bits per pixel are necessary to
provide a sufficient range of colours to provide a reasonably realistic representation of any
image. The number of bits per pixel is sometimes referred to as the colour depth.
Vector graphics
A colour depth of 8 bits per pixel provides 256 different colours. A bit depth of 8 bits per primary colour provides 256 × 256 ×
256 = 16 777 216 different colours. The eye cannot distinguish this number of different colours. However, this many are
needed if an image contains areas of gradually changing colour such as in a picture of the sky. If a lower bit depth is used the
image will show bands of colour.
Vector graphics
A bitmap file does not define the physical size of a pixel or of the
whole image. When the image is scaled the number of pixels in it
does not change. If a well-designed image is presented on a suitable
screen the human eye cannot distinguish the individual pixels.
However, if the image is magnified too far the individual pixels will be
seen.
Vector graphics
File size is always an issue with an image file. A large file occupies more memory space and takes longer to
display or to be transmitted across a network. Usually, a vector graphic file uses considerably less memory
space than a corresponding bitmap file.
You can calculate the size of a bitmap graphic knowing the resolution and the colour depth. As an example,
consider that a bitmap graphic is needed to fill a laptop screen where the resolution is 1366 by 768. If we want
colour depth of 24 then the number of bits we need is:
The result of this calculation shows the number of bits, but a size is always quoted as a number of bytes or
multiples of bytes. For our bitmap graphic:
25 178 112 bits = 25 178 112 ÷ 8 = 3 147 264 bytes
= 3 147 264 ÷ 1024 = 3073.5 kibibytes (3073.5 KiB)
= 3073.5 ÷ 1024 = approximately 3 MiB
Vector graphics
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.
Vector graphics
The following are considerations when justifying the use of either a bit map or a
vector graphic for a specific task.
8 bits 1 byte or 1B
1024 bytes 1 kilobyte (1kb)
1024 kilobytes 1 megabyte (1MB) or 1048 576 bytes
1024 megabytes 1 gigabyte (1GB) or 1 073 741 824 bytes
1024 gigabytes 1 terabyte (1TB) or 1 099 511 627 776 bytes
Since the image now has 8 bit colour, its needs 8 bits (1 byte to store the colour)
64 pixels X 8 bits = 512 bits
512 bits / 8 = 64 bytes
Example 4 – calculating file size from image
size and resolution.
Band-limiting filter
It is used to remove high frequencies which the human ear
cannot detect. These high frequencies will cause problems if
converted.
Analogue-to-Digital converter
The analogue to digital converter simply converts the analogue
signals to digital.
Sound
1. Lossless compression
The file size is reduced but no information is lost. The process can be reversed to re-create
the original file.
2. Lossy compression
The file size is reduced with some loss of information and the exact original file can never be
recovered.
Instead of having each character coded in one byte, the text is analysed to find
the most often used characters. These are then given shorter codes. The
original stream of bytes becomes a bit stream.
Compressing sound
Huffman coding can also be used for compressing a sound file. This is
effective because some values for the amplitude occur far more often
than others do. If a vector graphic file needs to be compressed it is
best converted to a Scalable Vector Graphics format. This uses a
markup language description of the image which is suitable for
lossless compression.
Compressing sound
Huffman coding can also be used for compressing a sound file. This is
effective because some values for the amplitude occur far more often
than others do. If a vector graphic file needs to be compressed it is
best converted to a Scalable Vector Graphics format. This uses a
markup language description of the image which is suitable for
lossless compression.
Compressing sound
5 a Sound can be represented digitally in a computer.
Explain the terms sampling resolution and sampling rate. [4]
b The following information refers to a music track being recorded on a CD:
– music is sampled 44 100 times per second
– each sample is 16 bits
– each track requires sampling for left and right speakers.
i Calculate the number of bytes required to store one second of sampled music.
Show your working. [2]
ii A particular track is four minutes long.
Describe how you would calculate the number of megabytes required to store this track. [2]
c When storing music tracks in a computer, the MP3 format is often used. This reduces file
size by about 90%.
Explain how the music quality is apparently retained. [3]
End of chapter
Test 2
Next up – Communication and
networking technologies