0% found this document useful (0 votes)
7 views57 pages

Chapter 1 Data representation

The document covers data representation in computers, focusing on number base conversions, including binary, octal, and hexadecimal systems. It provides methods for converting between these bases, including examples for converting decimal numbers to binary and vice versa. Additionally, it discusses the representation of binary fractions and the normalization of floating point binary numbers.

Uploaded by

chiyanjapeter7
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)
7 views57 pages

Chapter 1 Data representation

The document covers data representation in computers, focusing on number base conversions, including binary, octal, and hexadecimal systems. It provides methods for converting between these bases, including examples for converting decimal numbers to binary and vice versa. Additionally, it discusses the representation of binary fractions and the normalization of floating point binary numbers.

Uploaded by

chiyanjapeter7
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/ 57

i

ChapGFil
Data Representation
Chapter Objectives

Learners should be able to:


. convert one number base to another
. multiply and divide binary numbers
. represent binary numbers in twos complement
. normalise floating point binary numbeis
. change numbers to binary using character
sets
. represent data and character sets
. distinguish arithmetic errors

Introduction

Data representation is concerned..*g


th: way data in the computer is processed, stored
transmitted. Computers are basicalla classified and even
data in discrete form, whereas an"togu"
as digit"L *Jogo. o,l,yb.ij. ;il;;;,.rs process
comPuters Process both discrete data
and "o-p,rt..if."*r, ai." o"
i, .;il;;; ,rr"Lr..
continuous data. A computer can store different "runa
data which can range from sound, images, forms of
;i' *
videor, ,.xt. Digitar computers process data in
iJ represented"o-i"r,
two states oN and oFF. The oN state
by a and the oFF state is repreiented by a ..0i
The values "0" and'l,,are known
as binary digits fsit's).

Number Base Conversion

' This invorves converting a number in denary (base


l0) to binary (base 2), octar (base g) or
hexadecimal (base l6) ,,i.. u.r.".
"nd
' It also involves conversion ofbinary numbers to octal and hexadecimal and
vice versa.
a. Conversion from Decimal to Binary
. Divide the denary number by 2,lis6ng 6r" ."*ainders
until the answer is 0 remainder l.
' Take the remainders only from the lasi
one until the first as shown
t;i;;;;;;;rar a'ow in
the following example.

Erample

Convert 2l to binary

I
l'
We write down the
remainders from boftom
upwards to get the answer
l0l0l2
Example

Convert 12.75 to binary

I. The integer value 12


is converted as usual

. Therefore, 12 in binary
is I t002
IJ' The ns't stage is to convert the
decimar fraction 0.75 to a binary representation
. Multiply the decimal fracti
by 2' The whole number
to the right ofth. poirrt----on part ofthe result is the
first binr'
.75 x 2 - 1.5, the frst binar
ortr'e point is a r.
so ru,, *" i"u. .z;;;1.'ffiljorf' 'ist"
Next we disregard the
whole nr
b.y.2 olce again. The previous rezult (the I in
,n.,. part of this
this case) and md
right of the
;oint "Tllil*.ofthe
'umDer new resu.lt is the second
bi;*y;-;;
.5 x-2 = 1.9, the second binar,
to.the risht orthe point
so f"r, we h"ve.iif:i#.:'ii['j is a l.

We_will continue this process


until we get a zsro
E'Er d zero as our <lecimal
infi.nite repeating pattern. dec part or until we recogrb
ln fact, we do not need to
ru euntinue
co because we had 0 as
shown in ,hi, ;;;.' the fracuonal part of our real
Hence the representation
of12.75 = I100.1I z,
Infinite Binary Fractions

If for example, we are convertinga binary fraction to decimal and we notice that the steps to
be performed are exactly the same actions we had in the previous
steps we are then bound to
have an infinite binary fraction.

In other words, we will never get a 0 as the decimal fraction part ofour result but going to have
a repeating pattern.

For example, 3.1 converted to binary will produce the following repeating pattern:
It .00011001100110011 ... (base 2)
001I is a repeating pattern.

. Therefore, 3.1 in binary will be I1.0001lz

Example
Convert 5.37510 to binary

I. The integer value 5 is converted as usual

Therefore, 5ro in binary is l0l2

The next stage is to convert the decimal fraction .375 to a binary representation

0.375 yJ 0.750 (0 becomes the first value after the binarypoint)


0.75O x2 1.500 (l becomes the second value after the binary point)

1.500 x2 1.000 (l becomes the third value after the binary point)
(fractional part becomes 0, so we stop)

Therefore, 3.375ro -- l0l.0l l2

b. Conversion from Binary to Decimal

First, write the place values starting from the right to the left hand side, starting from 20 (ifthe
number is an integer)
Write each digit under its place value.

--L
j
. Multiply each digit by its corresponding value.
. Add all the products to get the denary equivalent.

Example
Convert l1 100 to denary

(1x24) + (txz3) + ela]t +(0x21) + (0x20)

(lxl6) + (lx8) + (lx4) + (ox2) + (0xt)

16 +8+ 4+0+0 = 28.

. Therefore, ll1002 to denary is 2g.

Example
Convert l0l.l I to denary
l0l.ll=l0l+0.11
l0l and 0.1I are converted separately and combined to produce the final answer
as indicated below.

lol =(k22)+(lx2o)
=4+l
=5

0.ll =(lx2-r) +0x2-2)


= 0.5 + 0.25
= 0.75

101.1I = 5.75 in denary

Example
Convert l l l l.l 1000 to denary

2t 27 26 2s 2' 2t 22 2r 20 2-t 2-2 2-7 2-4 2-s


256 128 64 32 l5 8 4 ) I 0.5 0.25 0.125 0.o62s 0.0312s
0 0 o o 0 I I I I I I 0 0 0

lt
t
-a

The binary number fractional binary number I I I l. I 10000 number represents I

8+4+2 + I + 0.5 + 0.25 = l5.75ro

. The following shows the equivalent representation ofan integer binary number and a fractional
binary number

Representation of an Integer Binary Number

MSB lBinary Digit LSB

28 27 26 2s 24 23 22 2r 20
256 128 64 32 l6 8 4 ) I
I 0 I 0 o o 0 0 0

The binary number 101000000 represents


256+54=220ro

Representation of a Fractional Binary Number

2E 27 26 2s 24 23 22 2r 20 2-t 2-2 2-t 2-1 2-5

2s6 128 64 32 l6 8 4 2 I 0.5 0.25 o.t25 o.0625 0.0312s

I o 0 0 0 0 0 I I I I I o 0

. The binary number 100000011.11100 represents


256+2+ | +0.5+O.25+O.125 = 259.87 5ro

Binary Fraction Place Value Fraction Decirnd


0.1 2-t % 0.5
0.01 2-2 Y" o.25
0.001 t, 0.125
2-? /a
0.0001 lt 0.062s
2-1 /r6
0.00001 l/ 0.03125
2-5 /32
0.000001 lt 0.015625
2-6 /64
Activity r
L Convert the following denary numbers into binary
a) 102 b)6.62s
2. Convert the following binary numbers into denary
a) tII1011 b) LL|U.NII
c. Conversion from Decimal to Octal
. Octal means base 8.
. Octal number contains only digits from 0 to 7.
. The same method used in decimal to binary conversion also applies on decimal to octal
conversion.
. Take the decimal number, divide it by 8 and then take the remainders only from bottom going
upwards as shown in the following example.

Example
Convert 88r o to octal

. Therefore, 88lo = 1308

Example
Covert 27ro to octal

. Therefore, 27ro = 33r+.*

Example
Convert 23.015625 to octal

(i) The integer value 23 is converted as usual

-r-

I
lr
?
. Therefore, 23ro is 27t

iii. The next stage is to convert the decimal fraction 0.015625 to an octal representation.
we
perform the same procedure as we did in binary but in this case we multiply
big.

0.015625 x8 0.125 (0 becomes the first value after the point)

0.125 x8 1.000 (l becomes the second value after the point)


(fractional part becomes 0 so we stop)

. Therefore, 23.015625ro = 27.01a

d. Conversion from Octal to Decimal

Exarnple
Convert 167r to denary

Power g4 g3 g2 gr go
Equivalent to: 4096 512 64 8 I
Octal Digits I 6 7

(1x82)+1dxa2;+17x8o)

(1x64)+(6x8)+(7xl)

64+48+7=ll9ro

. Therefore, 1578 to denary is llgro


Example
Convert 17.52s to denar
Power gr 80 g-r g-2
Equivalent to: 8 I o.t25 0.015525
Octal Digits I 7 5 2

\r
I
t7 =(lx8r)+(7x8o)
=8+7
= l5lo
0.52 = (5x8-r) + (2x8-2)
= 518 + 2/64

= 0.625 + 0.03125
=0.65625

17.528 =15+O.65625

= 15.65625ro

. Therefore, 17.52a = 15.65625ro

Activity 2

1. Convert the following dmary numbers to octal


a) es b) 4.6s

Convert the following octal numbers to dmary


a) 172 b) 3s.Ss

e. Conversion from Decimal to Hexadecimal

Hexadecimal means base 16.


A hexadecimal number contains numbers from 0 to 9 and A to F.
In hexadecimal A is equivalent to 10, B is equivalent to I l, c is equivalent to 12, D is equiva-
lent to 13, E is equivalent to 14 and F is equivalent to 15.
The table below illustrates this:

Decimal number 0 I ) 3 4 5 6 7 8 9 l0 ll 12 13 l4 l5
Hexadecimal equivalent 0 I 2 3 4 5 6 7 8 9 A B c D E F

' A hexadecimal number can be denoted using 16 as a subscript or addition ofeither a 0x or an {


ft sufix. For example, 56 in hexadecimal can be written as 56ro or 56fr or 0156. *

' The same method of dividing the number by its base as used on binary and octal conversions
I
and taking the remainders only also applies on decimal to hexadecimal conversion.

Example
Convert 20510 to hexadecimal
hr

\
i

(
E1
. C represents 12 and E represents 14'
. Therefore, 20610 = CEro

Example
Convert 97.3510 to hexadecimal

(e) The integer value 97 is converted as usual

. Therefore,9Tro is 5116

0.35 to hexadecimal rePresentation' we per-


(iv) The next stage is to convert the decimal fraction
in this case we multiply by 16'
ior- tt . ."rn" p.o.Jd,rr" as we did in binary and octal but

0.35 x 16 s5 (5 becomes the 6rst value after the


g.O tS b"..."t Oe second value after the Point)

0.5 x 16 9.6 (9 b..o-"t the se9!q4 value after the


il-(gb"--.t the second value after the
95 (, b..."t.t th" second value after the point)

. Therefore, 97.35ro = 6l59999rc

f. Conversion from Hexadecimal to Decimal

Example
Convert Dl ro to denarY

l6' l6t l6z l6t 160


Power
4 096 256 l6 I
Equivalent to: 65 536
D I
Octal Digits
(oxte r) + (lxl6o)
(l3xl6) + (lxl)
208 + l= 209rc

I
. Therefore, Dll6 = 20gro
Example
Convert A7.4D16 to denary

= (Axlor) + (7x16o)
=760+7
= t67ll
0.4D = (4x16-r) + (Dxro-2)

_ = (4xr6_r) + (r3xl6_2)
= 0.25 + 0.0507812s

47.4Drc = 167 + 0.25 + 0.05078125

= 1G7.30078t25rc

. Therefore, A7.4D6 _ 167.30078I251s


Activity 3

I ' coavert the forlowing denary numbers rnto hexadecimar


a) 1s7 Uag.2s
2. Convert the following hexadecimal
numbers into denary
a) A2Er6 b) 2A.s

g. Conversion from Binary to


Octal and Hexadecimal and vice
versa
ftli"r.-l'1" li|', ::m:,ffi1 **#: I**'*t,,u-i..] ,'r',"r, -akes conversion
amount of calculations. to be done straight away with
sa
minimum

I Convezrsion from Binary to


Octat
. The relationship between
binary and octal numbers is that
. Thus converting a binary
nu_t., a *,"f
octal (S) is 23.
i"i;::,':;'j::::^".tUIi
.un don€ with much ease bv puftins the
group of 3 uit.,it".tit* bits in
.,ffiJ,ffi";l:a #,*il,:T ;:il'":lf ;lj::#h a

;. ;;; ;;#; ge, 3 binary

l0
convert each group separately to its decimal equivalent, which will automatically be in base
8.
Combine the decimal values obtained to obtain the octal value.

Example
Convert 10001I l0l0l0l2 to octal
(i) Group the bits in 3s starting from right going to the left

00llooo l1l1lo10ltol

(ii) Convert each group separately to its decimal equivalent !


00I becomes I (in decimal)
000 becomes 0
lllbecomesT
010 becomes 2
l0l becomes 5

22 21 20 222' 20 22 2' 20 22 21 20 22 zr 20
001 000 ll I 010 l0 I
I 0 7 ) 5

(iii) Combine the values to obtain the octal number


10725E
. Therefore, l000l1l0l010lz = 10725a

Conversion from Octal to Binary


. Take each digit separately and then convert it to binary by dividing it by 2.
. Put each binary result obtained into 3 bits; ifthey are not 3 bits append 0s to the left.
. Take the binary digits and combine them into one binary number.

Example
Convert 527s into binary

(i) Convert each digit separately to binary


5 becomes l0l
2 becomes 010 (0 has been added to the left to make them 3 bits)
7 becomes lll

7
l0l, 010, I1l,
(ii) Take the binary digits and join them into one binary number
l0l0l0l1l

ll
. Therefore, 567" = t916161 1r,
Conversion from Binary to Hexadecimal

' Hexadecimal is a more convenient


short hand form to represent
' agan' the relationship between uin"ry data than binarv.
"nJt.#".,-J'rr_'i... i;#;:;:T].,-ar (16) is
. Thus binary bits are out in groups
. 1to the
of4, starting from the right going
teft)"d;;;;;;.;ii,, to the left.
ll$.r?i:r*tch 0s to its teft in order to get
"io*o 4 digirs in
. Each group is then separately
converted to its decimal equivalent.
' combine the values obturn.i ,"
ti. i"i"i."*"r ,"r*.. R.-"-b., that A represents
ll, C represents"ui"i"
rZ, O ..p*r.r,, 13, E r.p..r.nt, 14 and F represents
i3;"t,lffi*, lS in

Example
C.onvert I 1 10001 I l0l0l0l to hexadecimal
(i) Group the bits in 4s starting
from rigii going to the left

olllloooll llollorot
(ii) Convert each group separately to its decimal
equivalent
01f l becomes 5 (in decimal)
I l0l becomes D (13)
0001 becomes I
0l I I becomes 7 (0 has been added
to the left to make them 4 bits)

23 22 21 20 23 22 2'
0l
20 23 22 2L 20 23 22 2r
ll 0001 ll0I
20
7 I
010 I
D (t3) 5
(ii) Combine the values obtained

. 71D56
. Therefore, l l tO00l l l0l0l0 tz = 7tDlta
Conversion from Hexadecimal to
Binarv
. Take each digit separately and
then convert it to binary by dividing
it by 2
' Put each binarv result obt-T:1l""
bil;i';.;;;*d
. Take the binary digits and join 1 0s to the reft to make them
them into one binary number. 4 bits

Example
Convert 5CA16 to binary -ir
(i) Convert each digit separately to
binary
) Decomes 0l0l (append a 0 to the
Ieft to make them 4 bits)

12

f
C becomes I lfi)
A becomes l0l0
c A
01012 il002 l0l0z
(ii) Take the binary digits and join them into one binary
number
0l0l I l00I0l0z
. Therefore,5CAl616
= 0l0l I t00l0l0z
Activity 4

Using a minimum number


of calculations, cowert the binary number
IOMIOOIIIIilINt;
a) octal b) hexadecimal

2.
a) :r::y:m number of ca.lculations,' convert
Y:* " 2EF2I6 '--'-"vtv"a
the following numbers
to octal
uzsss
BinarySystem
' using.binary system the data is
represenred in two possibre states,
that is, 0 and I, thus in
' Most computing devices use the
binary number
rystem to represent electronic circuit vortage
state, which considers 0 vottage
input;r;;;; i;il;. input as on.
' The seguence of oNb and or-rt
rJt.t tr,.'.i..*Jlrj""s trat the computer
can under_
. The 0 or I is known as a binary digit.

Bit, Nibble, Byte and Word


' The terms bit' nibble, bpe
and word are rerated to computer
memory and data size.
Bit
. Bit stands for binary digit
r6tr which
wruLu c:ul
can be 0 or l. A bit is the basic unit
oe u
ers. ofdata in digital comput_

Nibble
. A nibble is halfa byte which is a group
of4 bits, for example, 0l10.

Byt"
' o a collection of 8 bits, for example,
0r 1000001, A group of 8 bits
l.:n-r represent a charac-

Word
. A word refers to a number ofbits
that a particular processor handles
at once.
l3
' The term word rength or word size is used to
measure the number of bits in each word,
for
example, 16 bits, 32 bits, 64 bits etc.
' Thus' word size affects processor speed as a 64
bit processor can process data faster than a 32
bit processor.
Advantages of Binary System
' It is easier to construct.electric circuits based on only
two binary values 0 and I or oN and oFF
logic rather than construct devices that can understand
forms of natural languages,
nuturl mjua. ar.i" ir,. diferent
' Binary data is arso reasonable simple to store - again
only needing a two state storage (on/off).
' calculations can be carried out using ,""ronubry simpie
active
"ele"-;;;;
circuits), since it only requires on and off(l ana b; sign"ls. ar-i-d" transistor
. All forms ofdata can be represented in binary sysiem format.
' Digital devices are more reliable, sman and uie iess
energy as compared to analogue devices.
' Binary codes are suitable for the computer applications
and digit"i.orrr-o.ri.ltlirrr.

Disadvantages of Binary System


. Difficult for most people to read.
' It takes alot ofdigits to represent any reasonable number (for instance to represent value 50, it
takes 2 digits in decimal and 6 digits in binary).

BinaryArithmetic
' Addition, subtraction, multiplication and division can
be performed on binary numbers in a
similar way as we perform the arithmetic operations
on de-nary numbers.

BinaryAddition
' In decimal addition, ifyou add,27 + 3 you get 30; to obtain the answer 30, the procedure is as
follows:

2 7 A3=l0.We diviile the total 10 by the base, in this case 10 to get


+ 3 I remainder 0. So we write the remainder 0 and carry the J-
3 0 2+1(the carry) gives us 3

' Similarly in binary addition wtren you add I and l; the


result is'two, written as l0 in binary,
we get, adigit 0 and a carry of l.
. Therefore in binary:
0+0=0
0+ I = I
l+0=l
I + I = l0 (which is 0 carry l)
l+l+l = ll (which is I carry t)

Example
l00l0l + l0l0l

t4
Explanation
l00l0l
+l0l0l
lll0l0
6rst column (from the right!) I+1=0carryI
second column : 0+0+ I (carried) = t
third column : I + I + no carry = 0 carry I
fourth column : 0+0+1(carried)=l
fifth column : 0+l+nocarry=I
sixtl column : l+0+nocarry=l

. Therefore, the answer is I I l0l0z


Example
Find the sum of the binary numbers lOf I I and I l0l0l

ll I ll {- Carry
l0 tll
+ I l0l0l
l00rr00
Example
Find the sum of the binary numbers 10001 and I I l0l

I I €-Carry
10001
+ I l10l
r0lrlo
Binary Subtraction
. |ust like in decimal subtraction, ifyou must subtract a one from a zero, you need to "borrow"
from the left.

Example
l0ll0ll - 10010 = l00l00l:

l0l l0l I
- 10010
l00l00l

Example
t0l0l l0 - t0l0l0

l5
00
+to+t 0110
- l0 l0l0
l0 lt00
Binary Multiplication
' Binary multiplication is actually much simpler to calculate
than decimal multiplication.
' In the case of decimar multiplication, we need to remember
4 x 9 = 36,7 x7 = 49, and so on.
' In binary mu.ltiprication, we only need to remember
the following:
0x0=0
0xt=0
lx0=0
lxl=l
Example
Multiply l0l by I I
1l0l
x ll
E:qplanation
First we multiply I l0l by l, which produces ll0l.
Then we put a 0 as a placeholder as we would in
decimal multiplication, and multiply I l0l by l, which
produces I l0l.

ll0l
ll0I
I l0 I 0 The 0 is the placeholder

Th^e-r'sults from our previous step indicates


that we must add I l0l and I1010, the sum of which is
l00l I l.
ll0l-
xl I
tI0 I
ll0l0
l00l I I d
il

Example t
il
Multiply l0l1.0t by l.t
l0l l.0l
l01l0l
l0ll0l0
I0000.1 I I

l6

I
I
' We multiply the binary numbers as we do in decimal. On the result we then
count the number
of digits after the binary point in the two binary numbers.
' In our example the first number has two digits after the binary point and the second
number
has one digit after the binary point.
. Therefore, the final result will have three digits after the binary point.
Activity 5
Find the product of the following binary numbers
(i) I0I and 10
(ii) 1100 and tI
(iii) t01I.0l anil 110.1

Binary Division
. Binary division involves knowledge of binary multiplication.

Example
l0l l divided by 11.
R10

0 +_remainder,R
OR
l01l divided by I l.

11 )11
I 1.0
tli)'tit
t01 I

-1tll
1

too
10
-11
ilitl
IJJII
1(
-11 I I
100

+ 0

' To get a fractional value, add a binary point immediately to the right of the fourth bit from
the
left and append a 0 bit. Bring down the 0 bit.
' In the above example, the binary fraction repeating is l0 and it will continue. So itt better to
stop at four or six fractional bit places and settle for I l.l0l0 orl l.l0l0l0
l0ll /II = Il R l0 1\
To check our answet we 6rst multiply our divisor I I by our quotient I l. Then we add its' product to i
the remainder 10, and compare it to our dividend of l0l l.

t7
l1
xl I
ll
+ll
l00l +-product of ll and ll
l00r
+ l0
I 0 I I <- sum ofproduct and remainder

Example
l0l I I divided by l0

10'l
1o\l oT1
=rcil
11
-10
1

Example
l0.l I I divided by 0.10

Step I
Remove the binary point from the divisor by moving it two steps to the right.
0,10 becomes OIO

Step 2
We must also move the binary point same nurnber of steps to the right as we did
on the divisor. Re-
member to add 0 bits as needed to fi.ll the new spaces.
l0.lI I becomes l0l l.l
Step 3
Discard/ignore the leading zeros on the dMsor. Then continue with the division
using the two binary
numbers as follows:
l0ll.l / l0

-10
11
-'t0
ll
-10
10
-i0

l8
Activity 6

Work out the following:


(i) 100/ 10
(ii) rr 1/1r
(iii) 1r.01/r.t
(iy) 10.11/0.010

Octal Arithmetic
. The addition and subtraction of octal numbers follows the same rules as the addition and
subtraction of numbers in any other number system.
. The only difference is in the borrowed number. In the decimal system, you borrow a group of
In the binary system, you borrow
1010. a group of2ro. In the octal system you boirow a group
of8ro.

Advantages of Octal Representation

. Easier to work with and read than binary.


. Conversions ofoctal to and from binary are straight forwar.d.

Octal Addition

Example
16s + 5s

I Carry
t6
+5 --
23

Example
256s + 2239

ll <- carry
256
+223
501
Octal Subtraction

Example
356s -273s

l9
lE Borrcw
,!s 6
_273 ---
63
Example
654s - l36s
g €_ Borrow
6as 4
_l 36
516

Hexadecimal Arithmetic
' The addition and subtraction of hexadecimal
numbers also follows the same rules
as thc
addition and subtraction of numbers in any
. nr_Uer system.
The only difference is in the borrowed "ii.,I" fro"a..i_"i-.yrt"^,
nu_U.L you borrow a grorry
of l6ro.

Uses of Hexadecimal

. To store instructional codes in the


computer.
. To represent locations of data in
memoiy (memory addresses).
. To represent web pages .oloor., fo..*"rrrpi.,
urfo'noo ,.pr"sents a red colour.

Advantages of Hexadecimal Representation

. Easier to work with and read than


a chain ofbinary digits.
. Easy to convert hexadecimal to and
from binary, '

Hexadecimal Addition

. Remember the following when dealing


with hexadecimal arithmetic:

Decimal number 0 I ) t 4 5 6 7 8 9 l0 ll t2
uexadecimal equivalent l3 T4 15
0 I 2 J 4 5 6 7 8 9 A B C D E F
Exarnple
i
4C66+ 28216
I
I ( Carry
4C6
+2 B 2
778 qtl

20

,
-
t
-
..-
Eramplc
4C66 + 28.26
I +- Carry
4C6
+282
778
Hexadecimal Subtraction

Example
35616 -27316
16 ts- Carry

_2 7 3
"56
E3
Example
3A5re -l82re

'i A5
.LB2
lF3
Hexadecimal Multiplication

Example
4A* C2

4 A
c 2

3 7 8 0

+ 9 4
3 8 I 4

Hexadecirnal Division

2t
Example
7s94lA

-6E
79
-78
14
-14
00
Activity 7
Work out the follon'ing:
(i) SBtc t 25rc
(ii) 127rc + SCta
(iii) 4EErc / /4rc
(iv1 BBhc - 6Dtc
(v) 67a + 25s
(vi) 124e / 27a
(vii) 5l4s * 27e

(viii) 462e - 76e

Integer Representation

. Integers are represented as pure binary numbers occuPying 2 or 4 bytes in comPuter


memory.
Coriputers use a fixed number ofbits to represent an intege,r, for examPle, 8-bit, l6-bit'
. 32-bit
or 64-bit.
. Two representation schemes are used for integers:
a) Unsigned integers: can rePresent zero and positive integers'
b) Signed integers: can rePresent zero, positive and negative integers.
. Signed numbers require an arithmetic sign
. Tlie most significani bit ofa signed binary number is used to represent the sign
bit.
. If the sign bit is equal to zero, the signed binary number is Positive; otherwise, it is negative.
. The remaining bits represent the actual number.
. The following ways are used to rePresent signed integers:.
a) Sign and Magnitude
b) I's Complement
c) 2t ComPlement

1f
I
Sign and Megnitude

the binary number.


The remaining bits in the number indicate the magnitude
(or absolute value).
bits represents
In a byte with-eight bits, the left most bit is the sign bit and the remaining seven
the magnitude of the number.
Sign biiO indicates that the number is positive, for example
0 l0l0l I I
Siln bit f indicate that the number is negative, for example -l 10l0l l r
the
d" ,"rrg. of numbers that can be reprJsented by sign and magnitude is obtained using
following formulae:
- l), where m is the number of bits in the register
- (2(m-r) -l) to + (2t--rl

Example
Ui r, find the range of numbers that can be represented using sign and
magnitude
U.i,,,i

- (2t--rl - l) to + (2t"'-tr - l), where rr = 8

-(27 -t)to+(27-t)
(-t27) to (+128-t)

-127 to +127

. Thus, an 8-bit signed number can represent data in the range


-l?7rcto +127rc
-I27:ro= llllllll and +l27ro = 0lllllll
. and the 8th bit is a sign
Given g bits, 7 bits are used to represent the number in binary form
bit in sign and magnitude data representation

Example
Using S-bits rePresent 15 in sign and magnitude

Sign bit: 0
Magnitude: 0001I I I

. Therefore, 15 in sign and magnitude using 8-bits is 00001 I I


I

Example
Using 8-bits represent ,0 in sign and magnitude .'\
Signbit: I
Magnitude: 0010100

23
. Therefore, -20 in sign and magpitude using and g-bits
is l00l0l00
Representation of zero (0) using sign and magnitude
'
zero (0) is set for a positive number o. poriti.rr.
zero and one (l) is set for a negative number
or negative zero.
' using sign and magnitude zero (0) has two representations;
10000000(-0) and 00000000(+0).
' since -0 and +0 are both just.O, it is very strange to
have two air.t *'r.p*r.n"tations for the
same number. This is one of the reasons that
a iimpre sign uit i, p.".ti*.
""i...J'i"
It Complement
. lt complement can be used to represent both positive and
negative numbers.
. Positive numbers do not change and they are iepresented as usual.
' If a'umber is negative *. .un ..p..rent it using onet complement by applying the bitwise
NOT to the number.
' Bitwise Nor is an oPeration on only one operand
that performs logical negation on each bit.
For example, the bitwise Not of l0l0z is 0l0lz
. Simply, in one's complement,0s are negated to ls
while ls are negated to 0s.
' The range ofnumbers that can be reprJsented in
rt complementis found iy the formula:
- (2'"-t-l) to + (2*-t-t)
where m is the number of bits to represent the number

Example
using 4-bits, find the range.rf numbers that can be represented
using ls complement.
- (2n-r- t) to + (2''-r-t) m = 4

- (2"-l) to + (2' -t-l)

- (23-L) to + (23-t)

- (8-l) to + (8-l)

-7 to +7

' Therefore, the largest number that can be represented


is +z and the smallest is -7.

Example
Using 8-bits represent (i) - t0 and (ii) _2 (iii) +7 in lt complement

(0 +10 = 000010102
-10 = II l10l0lz
(ii) +2 = 000000102
-2 = llllll0lz

t,
\z'
I
(iii) +7= 0000lllz
-7 = ltll000z

. However, 1t complement has two different representations for zero


(0):

+0 = 000000002
-0= llllll llz
Addition in I's ComPlement
. Addition is periormed by doing the simple binary addition of the two numbers.

Example
Using 8 bits, find the sum of 4 and 3

4 00000100
+3 00000011
7 00000111

Subtraction in I's ComPlement


. The main purpose-of using ones complement in computers is to
perform binary subtraction'
on the number being
Subtraction is achieved byirst performing the l's complement oPeration
subtracted then adding the two numbers'

Exarnple
Using a bits, find 8 - 4 in onet comPlement

(i) Rewrite the Problem as 8 + (-4)'


(i0 Convert -4 into onet complement 8-bits equivalent'
4 = 000001002
-4= lllll0llz
(iii) Add the binary equivalent of 8 to one's complement of -4'

8
00001002
+ (-4\ 111110112
[1] 000000112
L--42
2's Complement
. numbers in
Modern computers use two's complement to represent positive and negative
binary.
.Theusefulpartoftwo'scomplementisthatitautomaticallyincludesthesignbit.

25
Advantages of 2s Complement

. Two's complement allows a computer to add and subtract numbers using the same operations
without a need for circuitries to examine the sign of an operand (no need to implement adders
and subtractors),
. Zero has only a single representation, unlike in ones'-complement where it has two values
I1lIlllI (-0) and 00000000 (+0).
Twos complement enables higher precision arithmetic to be handled.

The twot complement notation is characterised as follows:


(i) A fixed number ofbits are used to represent numbers
(ii) The most significant bit is called the sign bit
(iii) Positive numbers start with a 0
(iv) Negative numbers start with a I
2's Complement representation of a positive number
. Positive numbers are represented normally.
. Convert the number to binary.
. RePresent the number using the required set of bits or append a 0 to the left of the binary
nurnber to make it positive
. However, the required set of bits may be given

Example
Using 4 bits represent 7 in 2's complement

7=LLI

To make them 4 bits prefix the result with a 0

. Therefore, T =0ILLz
Example
Using 8 bits represent 9 in 2t complement

9= l00lz

Append four 0s to the left to make them 8 bits

. Therefore,9 = 00001001u

2's Complement representation of a negative number


. Negative numbers are represented using 2's complement in a computer system. b\
. To obtain the 2's complement of a negative denary number:

26

\
\t'
a
Method I
(i) convert the magnitude of the denary number to its binary equivalent,
if it is not in
binary.
(ii) Append the appropriate number ofzeros to the left
(iit change the binary number to onet complement by changing the 0s to ls and ls to 0s
(iv) Add I to the result

Method 2
i' Convert the magnitude of the denary number to its binary equivalent, if it is not in binary.
ii. Append the appropriate number of zeros to the left
iii. Write all leading 0 bits starting from the right hand side as they are, including the first I bit.
Ifthere are no leading zeros, write the first I bit as it is.
iv. Thereafter change ls to 0s and 0s to ls to get the 2's complement of the number.

Example
Using 4 bits represent (i) -7 and (ii) -3 in two's complement

(i)
+7 0lll2
ls complement 10002
Add I +l

10012
-7= l00l z

(ii)
+3 001lz
Using method 2, write the first I from the right, thereafter, change the second I to
0 and the two 0s
to ls
-3= I l0lz

Representation of zero (0) in 2s Complernent

. There is no such thing as negative zero (-0). q

. Nonetheless, we can convert 0 to binary and get 00000000


l

. Changing 0s to lsweget llllllll


. Add I to the result, we get I 00000000.
. Ignore the ninth carry bit to get 00000000, since it represents an overflow
. We still arrive at 0 in binary for the eight relevant bits.
. Therefore,0 has only one representation, that is,00000000. \h

Addition in 2s Complement

' Addition is pertbrmed by doing the simple binary addition of the two numbers.
Example
(a) Using 5- bits, find the sum of9 and 5

9 010012
+5 00l0la
t4 0l1l0z
(c) Using 5- bits, find the sum of l0 and 7

l0 010102
+7 001 112

l7 10001z

Note. that the binary addition result is a negative number (-15), yet we have
added two positive
numbers, therefore, an overflow error has occurred

(d) Using 5 bits, find the sum ofl0, 12 and 15


l0 0l0l0z
12 011002
+t5 + Oil 112
37 l00l0t2
Note^that the binary addition result has 6 bits instead of 5 as required
by the question. Again an
overflow error has occurred. Also note that overflow bits are discard"d
a".h urithmetic operation.
Discarding the overflow bit gives a wrong result (+5). under this "ftur
circumstance, ttre sotution is to
increase the number ofbits for the register.

Subtraction in 2's Complement


' Subtraction is achieved by first performing the 2t complement operation
on the number being
subtracted then adding the two numbers.

Example
Using 8 birs, find 25 - 29

This is the same as 25 + (-29)


25 0001 10012
+(29\ lll000ll2 (+29=0001 ll0l2)
-4 ll1l1l00z

Example \r
Using4bits,find6-6
This is the same as 6 + (-6)
6 01102
+( -6) 1010e
0 ll100002
Overflow bit is thrown away to give answer as 0000 which is 0
Example
Using 4 bits, 6nd -63-94

This is the same as -63 + (-94). Therefore, convert -63 artd -94 into 2's complement and add the two
numbers.
(-63) ll00000lz
+(-94) t0I000l0e
lll 011000112

. Throw away the carry bit 1, to get the final answer as 0110001 l.
. The extra bit I indicates an overflow.
. The result above indicates an overflow as the result of adding two negative numbers cannot
give a positive answer.

Converting from binary 2's Complement to denary


. The 6rst thing is to determine whether the number is positive or negative.
. For positive numbers, we can simply convert the binary number back to decimal.
. For negative numbers, we fiist convert it back to a normal binary number and then prefix the
denary number with a negative (-) sign.
. A positive number starts with a zero (0) and a negative number starts with a one (l)
. The process of converting a negative binary number from 2's complement to denary is
accomplished using the following steps:

(i) Complement the binary number (Convert zeros to ones and ones to zeros)
(ii) Add one to the binarY number
(iiil Convert binary number to decimal
(iv) Prefix a minus sign
OR
(i) Subtract I from the binary number
(ii) Invert all the digits (Convert zeros to ones and ones to zeros)
(iii) Convert the resulting binary number to decimal
(iv) Prefix a minus sign

Example
Convert the 2s complement binary number 010000012 to denary
it starts with a zero (0).
The number is positive because

29
27 26 2s 24 23 22 2r 20
1286432 16842 I
0100000 I

=64+1
=65

Example
Convert the 2s complement binary number I I 1000102 to denary.

Method I
The number is negative because it starts with a one (l).

I I100010
Complement the number 0001t l0l
Add I +l
0001I I l0

Convert the binary to decimal 30


Prefix a minus sign -30

Method 2
Subtract I from lll000l0 I I100001
Complement the number 0001 I I l0
Convert the binary to decimal 30
Prefix a minus sign -30

Method 3
Use of weights

-, (-t* 27) + (t * 26) + (l * 2s) + (l * 2r)


-+ -128+ 64+32+2

-r -30
Range of numbers represented in 2,s Complement

' With two's complement representation there is no bit allocated as the sign bit
but the left-mocr
bit behaves like one.
' unsigred range refers to how many numbers you can represent if you only allow positir

30
numbers.
. Sg*a range refers to how many numbers you can rePresent if you require both positive and
negative numbers.
. Therefore, twot complement range is a signed range since
it represents both positive and
negative numbers.
Foi example, the range ofnumbers that can be represented in an
8-bit register:
xior unsignei numbers will be from 00000000 (0) to llllllll
(255)'
(- to 0l 1l I I I I ( 127).
xFor signJd twot complement range is from 10000000 128)
that can
fh" following iormulae can be used to find the largest number and smallest number
be represented in 2t comPlement:

- (2m-r) to + (2m-r-l)
*ir.r.rrr is the number of bits used to represent the number

Example
using 2's complement
fina ifr" h.g"rt number that can be represented in an 8-bit register

- 12m-r) to + (2m-r-1;
- (288-r-t) to + (28-1-l)
-(27) to + (27 -t)
-L28 to + L27

. (100000002 ) and the largest number is 127 =


Therefore, the smallest number is -128 =
(01l l l ll I z).
.UsingSbitstorePresentanumber,iftheresultofcalculationproducesaresu]tabove+127
then it is called overflow.
. ti the result produced is less than -128 then it is called underflow' tec
Additional material coming

Activity I
1. Usiig S bits reptaent the decimal number -28 in
(a) Sign anil magnitude
(b) 7's comPlement
(c) 2's comPlement
can be representeil in
Z, Wi"g e Uii *rnPute the llrgest and smallat numbers that
( a) sign an il magnitu ile
(b)l's comPlement
(c)2's comPlement
3 , IJsing 8 bits pnfotm the following calculations using
(a)l's comPlement
(b)2's comPlement
(, 28+2
(ii) 14-8
(iii) -2t-8
3l
Fired Point Arithmetic

The term 'fixed point' refers to


the corresponding manner in which
with a fixed number of disits after, and numbers are represented,
,";;d;;;;, the decimal point.
F-or example, a fixed -poinirepresentation
with a uniform decimar point pracement
the numbers 126.4s, 1264.s6, 126as.67, convention
illn:tot"ttnt
etc with two digts
"t".
ii.-J*t-a
Fixed Point Binary Number System

' Ttre fixed point number representation


assumes that the_binary point is fixed at one position.
' The binary point is not actually present
in the registea but its presence is assumed
based on
whether the number which is sior"d is
fraction-ir-an integer.
. Thus fixed point numbers can either "
be fractional orinteger.
Fixed Point Integer Representation
' The register used to store an integer value win be as follows:

. There is no memory space for the


binary point.
' However' computers rePresent a finite
number of digits and this limitation allows
us to evaluate
the maximum and minimum posribl.
can be represented.
";b;.;;;at
Ma*imum positive Number
Positive numbers start r,rrith a 0, thus
0l I I I I ll = a127

Minimum positive Number


This evaluates to 00000001 +l
=

Smallest Magnitude Negative Number:_


Negative numbers start with a l. This gives
us llllllll = _l
Largest Magnitude Negative Number
This is 10000000 = _128

Range ofnumbers that can be represented


The overall range of numbers thati- b..fr.r.rted I
is given by the following formulae: li
_2m-r to 2m-r_ I ll
N

where m is the number of bits to represent


the number tL

Example
using an 8-bit register, find the range
ofnumbers that can be represented
-2m-r to 2m-r_l

32
_2E- l to 28-l-l
-27 to 27 -l
-128 to + 127

Fixed Point Fractional Binary Numbers

. The binary point is fixed at one Position and therefore does not move'
. Given one byte to hold each number, and assuming that there are 7 bits after the imaginary
binary, the fractional binary number may be shown as below

BinarY Point

using an 8-bit register with the imaginary binary point 6xed after the sign bit, one can calculate the
maxiinum positiie number, minimum positive number, smallest negative number and the largest
negative number as shown below.

Maximum Positive Number

This becomes 0.1I l-r/na = O.9921875


1l1l I =
Alternatively, this can be calculated as follows:

20 2-t 2-2 2-3 2_4 2-5 2_6 2-7

0 I I I I I I I

*Z-2 + | *2's + I *2'4 + | *2-5 + | *26 + I *2-7


= 0*2o + I*2-r + L
= 0.5 + O.25 + 0.125 + 0.0625 + 0'03125 + 0.015625 + 0.0078125
= o-992t875

Minimum Positive Number


th7
This evaluates to 0.0000001 = = o.oo78l25
Alternatively, this can be calculated as follows:

20 2_r 2-2 2-3 2_4 2-5 2_6 2-7

0 0 0 0 0 0 0 I

| *2-7
0.0078125

33
Smallest Magnitude Negative Number

This gives us 1.llIll11 ='/r'


=o.ooTstzs
Alternatively, this can be calculut.4 q&!!9.I
20 2-r 2-2 2-3 2_4 2-5 2-6 2-7
1 I I I I I I 1

-y2o 1y2-r +lrZ-2 +1*2-3 + l*2-4 + I *2-5 * 1*2-6 * 1t2-7


-l + 0.25 + 0.125 + 0.0625 +0.03125 + 0.015625 + 0.0078125
0.0078125

Largest Magnitude Negative Number


This gives us 1.0000000 = -l
Alternatively, this can be calculated as follows:

20 2-r 2-2 2-3 2-4 2-s 2-6 2-7


I 0 0 0 0 0 0 0

r *ro
= -l
. Remember that 2t complement negative numbers start with a I and positive numbers start
with a 0.

The imaginary binary point can be fixed on a stated position. The following is an example
ofan 8-bit
6xed point fractionai binary number with an imaginary binary point after the fifth digit

10001001
l
I
I
Imaginary fixed binarY Point

Example
convert the
Uslng in 8-bit byte to hold each number, with the binary point fixed after the fourth digit,
decimal number 7.5 to binarY.

7 = 0lll
0.5 = 0.1
=01 I 1.1000 (Three trailing 0s are added to make it one byte)

Example
\r
Assuming 3 bits after the imaginary binary point, convert the binary number 000001l0l I
to decimal.

34

I
000001101I
A
I
I
Imaginary fixed binarY Point

000001LOl I

26 25 24 23 22 2r 20 .2r 22 23

64 a) I6 842 I 0.5 0.25 0.125


0 0 0 001 I .0 ll
=2+l+O.25+O.lZ5
= 3.375

Example
Represint -7.25rcin 8-bit binary with the binary point after the fourth digit'
nint: With a negative number we have to apply two's complement always'

23 22 2r 20
,' -l
2-2 2-t 2-1

8 4 1 I 0.5 0.25 0.12s 0.0625

Step-l
Cal-date the positive equivalent number in binary'

Step-2
Change 0s to ls
and ls to 0s (Complement). I

Step-3
Add I to the result. t
.l0ll-
Advantages of the Fixed Point Binary System

. It preserves accuracy as required.


. It is easy to convert.
Disadvantages of the Fixed Point Binary System

. It has a limited range. '\


. Very small numbers and very large numbers cannot be rePresented'

35
Floating Point Arithmetic
' The term floating point is derived from the fact that there is no
fixed number of digits before
and after-the binary point; that is, the binary point can be placed anywhere (float)
relative to
the signifcant digits of the number.
. Floating point numbers are represented using 2t complement
. Floating point representation can handle a wide range ofnumbers, for example, a fixed-point
rePresentation with a uniform decimal point placement convention can repreient
the numbers
123.45, 1234.56, 12345.67, etc, whereas a floating-point representatio; could
in addition
represent 1.2345 67, 123456.7, 0.0000 1234567, I 234562000000000, etc.

Mantissa and Exponent

.' The structure of a floating point number is shown in the following diagram
The floating point rePresentation ofa number has two parts namely mantissa and
exponent.

Point

Bit Sign Bit

bl/ I
0 1 1 0 1 1 6 0 0 0 0 0 0 1 c

<-__- Mantisa __--___-_______>


Exponent
The mantissa is the fractional part of a number that stores its main value.
---------t
The Mantissa is always a fraction and the left most bit of the mantissa is a sign
bit.
The binary point can float (move) and be placed at any position of the mantissa
The Exponent is always an integer and can be positive or negative depending on
its sign bit.
The left most bit ofthe exponent is a sign bit.
The exponent shows the position of the binary point in the mantissa. It tells us how
many
p-laces to move the binary point to the right or to the left so as to get the
original value.
If exponent is positive we mov! the binary point to the right. If the expon-ent is negative we
move the binary point to the left.
Consider the numbet 723: it can be written using exponential notation as: I,

l. 7.23 x t02
2. 72.3x l0r
3. 723 x l}o

4. 0.723 x 103
5. 723O x l}'r

0323 x t03 hrrr

36

\ lr

t\ y''
e
. and the exponent 3' The exponent 3 means
This means we need only store the mantissa 0'723
places to the right'
we move the decimal point of the mantissa three

Now the same with Binary Ftoating Point Representation


. The same can be done i" ii""ti*a,nis foims the foundation of our floating Point number'
. The floating point number will be represented as follows:
Mantissa x 2E*Pontnt
.Sinceweneedonlytostorethemantissaandexponent,thebinaryfloatingnumberis
represented as follows:

Mantissa / ExPonent
.Using8bitsforthemantissaand4bitsfortheexponentthebinarynumber0'0001lllcanbe
represented as follows:

(i) 0'0001111 x 20
00001111 0000 (Mantissa: 000011l l ExPonent:0000)

(ii) 0.001I110 x 2-1


000llll0 llll

(iii) 0.0lltl00x2-2
00111100 1ll0

(iv) 0.1111000 x 2-3


0lll1000 l10l

Notethatifthebinarypointtpositionisnotshowninthemantissa,itimpliesthatitispositioned
between the two left most bits.
as shown above'
in noutirrg point, a number can have dilferent representations

denary number -13. 25 to a floating-point


binary representation with 8-bits for the
|l#.nl"rn"
mantissa and 4-bits for the exPonent'

First convert 13.25 to binarY

zs 24
.3
z. .2 tl 20 . 2'r 2-2

32 16 842 I 0.5 0.25


I .01
number (- 13'25)'
Perform 2's complement since it is a negative denary
001l0l.0l becomes 110010' l l

37

I
Move the binary point 5 steps to the left to ga the following:
l.l00l0l I

To get our decimal point back to where it started, we need to move 5 places to the right. Therefore, 5

now becomes the exponent.


l.l00l0t1 0101

Therefore, -13.25to = l100l0l I 0101 in binary floating point

Converting a Floating Point Number into denary.


The following are the stages to follow when converting a denary number into binary floating point

l. Find the sign of the mantissa (make a note of this).


2. Find the value ofthe exponent and whether it is Positive or negative.
3. Move the binary point the distance the exponent asks, left for a negative exponent, right for I
positive exponent.
4, If the mantissa is negative Perform twot complement on it.
5. Starting at the binary point, work out the values ofthe mantissa.
6. Refer back to the sign you recorded on the sign move.

Example
A number is represented as an 8 bit floating point number. 5-bits are used as the mantissa and 3- bits
are used as the exponent. Both the mantissa and the exponent are in two's complement.
Show the following floating point in its denary equivalent:
a) 0llll0ll
b) 11000 110
a) 0llll0lr
0llll0I1
Mantissa: 0l I I I (0 means its positive)
Exponent: 01 I (0 means its positive)
The exponent is 011 (3 in denary)
Therefore, move three steps to the right to get the original binary number
0llll becomes lll.l
Convert I I l.l to denary

22 2r zo 2r
421 0.5
lll I

11I.1
=4+2+l+0.5 c.i

38
b) rloo0 lro

11000 I l0
Mantissa: I 1000 ( I means its negative)
Exponent: ll0 (1 means its negative)

since it is negative
Perform 2's complement on the mantissa
11000 becomes 01000
get the original binary
The exponent is 110 (-2 in <Ienary)'
Therefore' move 2 steps to the Ieft to
number
01000 becomes 00010

Convert 0.0010 to denarY


2_t 2_2 2_3
20
0 0.5 o.25 0.t25
0 0 0 I

=0+0+0+0.125
= 0.125
is negative)
= -0.125 (Since the mantissa

Advantages of Floating Point RePreserrtation and very large


. Floating poin ,tp'""n*io" has the ability to represent very small numbers
numbers.
. They can handle a larger range of numbers'

Disadvantages of Floating Point Representation repre-


are slower and less accurate than fixed-point
.
Floating point ,.p"""t"ltion' gJ*rally
sentations.
dealing with large or very small values
. Lose a little bit of accuracy when -very
fo, in binarv, 0.0001I I lcan be written
. A number can have dtff.r;;;;;;;;;;;onr, "*"rnpl.,
asfollows:
00001111 0000
000ltll0 lrlr
00111100 l10l

number. s bits are used as the mantissa and 3


!:'Xtt:"10* u reprcsented as an B-bitJroatingpoin-t
i"tttii tnil the exponent are in twos complemett'
bits are used as th" ,*po,"'i"n"ii'n"
siii rn" fanning fliating point in their
iletary equivalent:
(a) ltltl olt
(b) 01011 tlt

39
2' work out the binary foating point for the denary number 97, using ro bits
for the mantissa s
6 bits for the exponent.

Normalisation of Floating Point Numbers

' Normalisation is the process of moving the binary point on the mantissa so that the 6rst digr
after the point is a significant digit. This is done to simplifr operations and expressing numbc:
in standard form.
. The binary point is always between the Sign bit and the Most significant Bit (MsB).

Bianary Point

Sign Bit

Mantisa Exponent
. ----------{
For a floating point binary number to be normalised, the first two bits of the mantissa mu$ h
diferent. That is:
1.0 or 0.1 and definitely NOT l.l or 0.0

. T5, if the mantissa is positive, the Sign Bit is always 0 and the MSB is always I (0.1).
. If the mantissa is negative, the Sign Bit is always I and the MSB is always O(i.0).
. For a negative number, there must be No leading ls to the left of the MSB, except the sign

r.uooilrx
. For a positive number, there must be No leading 0s to the left of the MSB, except the sign b3L

o.oroilux
' With positive numbers, the binary point in the mantissa is always placed immediately befolr
the first non-zero digit because it allows us to use the maximum number of digits.
Zero cannot be represented in normalised form. This is because 0.0000000 th; first two digit3
are the same.
A normalised value must have the first two bits of the mantissa different. Usually, the computcr
uses the smallest positive number to represent zero.
To maximise the precision of a positive number you should have a mantissa with no leading
zeros.

40
leading
. number you should have a mantissa with no
To maximise the precision of a negative
ones.

Example
floating point binary number'
iio#t, rfr. denary number 39'75 as a normalised
.- I rz )-3
27 26 2s 24 zt 22 21 20

16842r 0.5 0.25 0.125


izs6432 110
00lo0lll
00l00l l l.l l0
left to get the following:
Move the binary point 6 steps to the
00.l00lllll0
(5 now
point back to where it started' we need to move 6 places to the right
To get our decimal
becomes the exPonent)
0.100111110 000110

Therefore, 39J5 rc= Ol00l I I I 10 0001


l0

and
floating point number using 8-bits mantissa
:ffi.[. decimal fraction _5.25 to normalised
4-bits exPonent.
the negative sign to get the following:
convert the fraction -5.25 to binary ignoring

22 2r 20 2-r 2-2
J I 0.5 0.25
4
I 0 I 0 I

t0l.0l
the left
Move the binary Point 3 stePs to

0.1010100 (add 2 zeros to get 8 bits


for the mantissa)

Theexponentbecomes00ll(3indenarysincethebinarypointmustmove3stepstotherighttoget
back to the original value)
convert 0'1010100 to twos complement
Since the number is a negative one
1'0101100

Therefore, -5.25 becomes l0l0l100


001 I in normalised floating point'

Example
0'010000000 | 000011
Normalise the following floating point number
!
4l
Convert the exponent to denary.
The exponent is positive.
000011 is 310

The mantissa is positive' The number starts


with 0,01 and we need to change this so that
0 l for it to be normarised. To do this we ne.a it starts with
to -ou.
must subtract one from the exponent to compensate
ii.
iinary point one position to the right. we
for the movement ofthe binary place one place

So it becomes 0.100000000 x 23 - 1
_ _0ooo0r)
0.100000000 x 23 r(oooor r
0.100000000 x 22(oooolo)

0.100000000 | 000010
Or
0.010000000 | 000011 = 0.100000000 000010 (00001t _
| 000001)
- I is to compensate for the
movement of the binary point orr" piu." to tfr" t"n
Therefore, 0.100000000 000010 is the
| normalised floating point number.

Example
Normalise the following floating point number
l.l10000000 | I I I I l0

Convert the exponent to denary.


The exponent is a negative number, therefore
perform 2t complement.
1l I I l0 becomes 000010
000010 = 2
lllll0 = _2 in denary

The mantissa is atso negative. It starts with


l.l I and we need to change this so that it starts
with 1.0 for
it to be normalised' To do this w_ e need to move
the binaf point two positions to the
right.
subtract two from the exponent to compensate we must
for the movement ofthe binary place two places
reft.
So it becomes 1.000000000 x2-r-2
_2_2(l rl I ro_ooooro
1.000000000 x 2

1.000000000 x 2-4(r l l roo

r.000000000 llllto0
Therefore, 1.000000000 I I I 100 is the normalised
\,
| floating point number.

42
normalise the binary number
3:il1[., ar.he mantissa and 5 bits for the exponent'
0.000101011

Move the binary Point 3 Positions


to the right to get the following:
0.l0l0l I get the following:
Compensate forii" n"rnUt' of bits by appending two 0s to
0.l0l0t 100
get back to the
-3 since the binary Point has to move 3 steps to the left to
The exponent becomes
orieinal binarY number' 3(1 r I ror)(-3 is 1 I I l0l in two's complement)
0.l0I0l l0 x 2
0l0l0l l0 tI l10I in normalised form'
Therefore, 0.00010101I becomes

exponent' normalise the binary number


3:ffi3t"r* ar,ne mantissa and 5 bits for the
011101.11

Move the binary Point 5 Positions


to the left to get the following:
0.11l0l I I
to get back to the
becomes 5 since the binary point has to move 5 stePs to the right
The exponent
original binarY number'

o.lllolll x 23(ooror)
11 l0l I I 00101 in normalised form'
Therefore, 0l I 101'l I becomes 0l
to Denary
lt"""t,i"g. Normalised Floating Point Number
ExamPle
number to decimal
Convert the following normalised
010000 ll00

Mantissa: 0I 0000
ExPonent: 1100

exponent is negative
The mantissa is positive and the
(4)
exPonent so that it becomes 0100
Convert the negative 2's complement
-4
Since it is a negative it becomes

4 steps to the left


Move the imaginary binary point
0'10000 btto-"s 0'00001
Convert 0.00001 to denarY

43

€ -J.f..idEEl
20 2-r 2-2 2-3 2-4 2-s
I 0.5 0.25 0.125 0.062s 0.03125
0 00001
Therefore, 010000 I100 = 0.03125 in denarv

Example
Convert the following normalised floating
point number to decimal
l0ll000 ul0
Mantissa: l0r 1000
Exponent: lll0
The mantissa is negative and the exponent
is negative

Convert the negative 2's complement


mantissa so that it becomes 0I01000

Convert the negative 2,s complement exponent


so that it becomes 0010 (2)
it is a negative it becom;s _2
Since

Mo^ve the.imaginary binary point 2 steps to


the left
0.101000 becomes 0.001010

Convert 0.001010 to denary

)o .-l 2-2 2-3 2-4 2-s 2-6


I 0.5 0.25 0.125 0.0625 0.03125 0.015625
00 01010
Il8+U32=5132
0.125+ 0.0i125 = 0.15625

Since the mantissa is negative it becomes _0.1562


Iheretore, l0llfi)O lllOO =_ O.lS62Sin denary

Advantages of Normalisation
' Ensures that a single representation
ofa number is maintained (standardisation).
' Ensures maximum possible accuracy
ismaintai;;; a given number of bits.
. S_*: space by using the space given in an
efficient wav.
. Can be used to detect er.o, .orrdition.
,u.h u, urrd..fl'or and overflow
' Tries to maximise the range ofnumbers
th"t.- t;t.pr;sented in a fixed point representation
(range and accuracy is limited
in fixed point ,.pr.r*iJor1.

and Precision/Accuracy of Normalised


Floating point Binary Num_
ff:*"
' The size ofthe exponent determines the range ofhumbers
that can be represented.
44
Increasing the number of bits in the exponent increases the range but this will also decreases
precision.
Reducing the number of bits in the exponent will reduce the range but this will also increase
accuracy because more bits are allocated to the mantissa.
The size ofthe mantissa determines the precision ofthe numbers that can be represented
Precision can be increased by increasing the number of bits that are used to represent the
mantissa but this will decrease the range.
The only way to increase both range and precision is to use more bits for the exponent and the
mantissa.
If we use more bits for the mantissa we will have to use fewer bits for the exponent and vice
versa.

Number Ranges in Normalised Floating Point Representation


. Let us start otrby using 8 bits for the mantissa and 8 bits for the exponent for expldnations
below:

Number Mantisa( 1 Bvte) Exponenl (lBytes) Ranqe Calculation Comm€nts


Larqest +ve Iarsesuvr- Furthest from 0
Large +ve 0lllllll 0llllll I 0llllul 0ulllll
=> lx 2t17 => 2r2'

Smalle st +ve Smallest +v€ Closest to 0


Smallest +ve 01000000 10000fi)0 l0llllll 10000000 Used as 0 in FP
=> 0.1-t2t x 2-r2e representations.
Roughly Normalised

Larsest -Ye Smallest -ve Closest to 0


Largest -ve l0llllll 10000000 l0lllnl I
10000000

Roughly Normalised
t
-v€ converston
_0.1000001 x 2-,rr

Sna[e$-vl- Larsest +ve Furthest frorn 0


Smallest -ve 10000000 0lllllll ---r-
10000000 0rllrlll
+ve Jo.rversion
=> -l x 2127 => -2r2,

Using information in the above table:


. The largest positive value we can have for the mantissa is 0.1 I I I I I I.
. The largest positive number we can have for the exponent is 0l I I I I I 1.

. This means that we have 0. I I IIII I x 21 I I I I I 1 = 0. I I I I I I I x 2127.


. This means that the largest positive number is almost I x 2127
Also:
. The smallest positive mantissa is 0.1000000.
. The smallest negative exponent is 10000000.

45

l<+
' This represents 0.1000000 x 2 rooooooo - 0.1000000 x 2-l2s which is very close to zero;
in fact, it is 2-12e.

On the other hand:


. The largest negative number (i.e. the negative number
closest to zero) is
l.0lIIIII x2loo0o0oo = -0.1000001 *2-r2a.
' We cannot use l.1lI I I I I for the mantissa because it is not normalised.
The first two digits
must be different.

Furtherrnore:
' The smallest negative number (i.e. the negative number furthest
from zero) is I.0000000 x
2orrrllrr = -1.0000000 x 2r27 -2127 . -
Activity l0
I' using t0-bit mantissa and a 6-bit exponent, normalise the
following numbers:
(a) 0 0000{1100 (nlrn
(b) 1101110010 0(n011

2' what is the decimal value for the following binary pattens if the
first g bits is the orrtissa
and the last 4 bits are the e*ponent?
(a) 1o1il100 il10
(b) 0to1 woo trco
3, using lo'bit mantbso anil 6-bit e4,oner.t, represent the
folhwing decimal numbers using
n or m ali s e d fl o ati ng point r epres ent ation :
(a) 2s.27s
(b) -8.5
(c) 143

Computer Arithmetic Errors

Round-OffErrors
' Rounding is expressing a number to the nearest whole/decimal/binary number.
For exam-
ple' 3.9569 rounded to 3 decimal places is 3.957.If rounded to
the nearest whole numbet it
becomes 4.
' often
-we
cannot represent a denary fraction exactly even if we allow many bits in
memory.
Therefore, the number stored is "rounded off" to the closest possible
binary equivalent.
' In rounding, the least significant bit may be increased depending on digits
removed. The
result should represent the value that is nearest to the original viue.
Foi example,
100.1 = 100 (Rounded_offto 2 significant 6gures)
ll0Il = 11000
(Rounded-offto 2 significant figures) \
ll.l0l = 100 (Rounded-offto 2 significant 6gures)

1100 = ll00 (Rounded-offto 3 significant figures)

46
l10l = lll0 (Rounded-off to 3 signifi cant fgures)
. When rounding off, guard against changing the value of the number to become less than it
was before.

Truncation Errors
. Truncation is shortening by cutting offsome characters abruptly at a certain point.
. For example, 3.9569 truncated to 3 decimal places become 3.956. If truncated to the nearest
whole number, it becomes 3.
. Truncation error is the difference between a truncated value and the actual value. A truncated
quantity is represented by a numeral with a fixed number of allowed digits, with any excess
digits'thopped off"
. Often, in either floating or fixed point systems, results are calculated with too many places of
accuracy to be represented.
. We get this type of error when trailing bits are truncated to fit the result in the memory location
available.
. Truncation works as follows:
100.1 = 100 (Truncated to 2 significant figures)
l0l0l= 10000 (Truncated to 2 signifrcant figures)
ll0ll= 11000 (Truncated to 2 significant figures)
ll.l01 ll
= (Truncated to 2 significant figures)

Overflow and Underflow


. Since we are working with numbers contained in a fixed number of bits, we must be able to
detect overflow and underflow errors following an operation.
In signed binary arithmetic, overflow and underflow indicate errors.

a. Overflow
Overflow occurs when a calculation produces a result that is greater in magnitude than that
which a given register or storage location can store.
. In other words, the result is greater than the number ofbits available to represent the result
value,
. Overflow occurs when a number is divided by a small number or when two large numbers are
multiplied together.

Detecting Overflow
(i) The sum of two numbers with the sign bits of produces a result number with the sign bit on.

Example, using 4 bits

4 0100
4 + 0100
8 1000 (Overflow has occurred because 8 is out ofrange)

. Using 4 bits, the range of numbers to be rePr€sented is 1000 (-8) to0lll (+7)
(ii) The sum of two numbers with the sign bits on produces a result number with the sign bit off.
Example, using 5 bits
. 8 0lm0
+8 + 01000
15 10000 (Overflow has occurred because the result now represents a nega-
tive number -16 (10000))

'
If you are doing twob complement (signed) arithmetic, overflow occurs when;
Suppose x and yboth have sign bits with value l. That means both represent negative
lt] numbers.
Ifthe sum has sign bit 0, then the result ofadding two negative numbers hasiesulted iria non,negative
result, which is clearly wrong.
(ii) Suppose x and y both have sign bits with value 0. That means both represent non-negative
.
numbers. If the sum has sign bit l, then the result ofadding two non-negative numbers has resulted
in a negative result.
'However, when a negative and a positive number are added together, overflow cannot occur
because the sum is between the two numbers.
'If you are doing two's complement (signed) arithmetic, overflow flag ON means ihe answer is
wrong.
'Ifyou are doing unsigned arithmetic, the overflow flag means nothing and should be ignored.

b. Underflow

' Underflow occurs where the result ofa calculation is ofvery smaller value (close to zero) than
the smallest value that the computer can actually represent in memory.
' Underflow occurs when a small number is divided by a large number or when small numbers
are multipted together.

Activity 11
Perfurml calculation on the follo*ing signed binary numhers and indicate whether they produced
an overJlow or not:
i) |OOO + 1000
ii) 0l(N + 0(NI
iii) 0rI0 + ilnr
iv) 0000 + (n01
v) 1100 + 1100
Actual error
' Actual error or absolute erroris the difference between the exact/actual value and the computed
value.
. Actual error is obtained by the following formulae:

Actual error =Exact value - Computed value

An exact value is the actual value that is not estimated.


A computed value is the value that is obtained after estimation.
Relative error \r
. Relative error is obtained by the following formulae:
Relative error= Actual error/Exact value

48
Example
2/3 is approximated to 0.666. Find the actual error and relative error.

l. Actual error

Exact value = 2/3


Computed value = 0.666
Actual error = Exact value - Computed value
= 213 - 0.666
= 2l30o0

2. Relative error
Relative error = Actual error/Exact value
= (2t3000) | (2t3)
-- 213000 x312
= 0.001

Character Set
. A character set refers to all the characters that a computer system can recognise, which often
equates to characters on the keyboard.
. The characters within a character set can be letters of the alphabet, numbers or symbols.
. Each character is represented by a number, for example, the ASCII character set uses numbers
0through 127 to represent all English characters and special symbols.
. The following are examples ofcharacter sets used by general computers to represent characters:
* American Standard Code for Information Interchange (ASCII)
* Unicode 1

* Binary Coded Decimal (BCD)


* Extended Binary Coded Decimal Information Code (EBCDIC)
American Standard Code for Information Interchange (ASCID
. ASCII is a way ofassigning bit patterns to the characters on the keyboard'
. Each character has a unique ASCII code
. The ASCII code associates an integer value for each symbol in the character set, such as letters,
digits, Punctuation marks, special characters, and control charCcters.
. ASCI is widely used in computers of all types and communications equiPment.
. ASCII codes can just be used for representing characters and not for arithmetic calculations.
. There are two types ofASCII codes namely ASCII-7 and ASCII-8.

a) ASCII-7
ASCII-7 is a 7-bit standard ASCII code.
The first 3 bits are the zone bits and the next 4 bits are for the character.
ASCII-7 allows 128 characters to be represented, that is,27= 128 combinations'
b) ASCII-8
Manufacturers have added an eight bit to the ASCII-7.
.A,SCII-8 allows 255 characters to be rePresented, that is,28 = 256 combinations.
ASCII-8 has 4 bits for zone and 4 bits for the character.

49
ASCII Character Set
. Codes 0 to 3land 127 represent non printable control characters.
. Codes 48 to 57 stand for numeric values 0-9.
. Codes 65 to 90 stand for uppercase letters A-2.
. Codes 97 to I22 stand for lowercase letters a-2.
. Codes L28 to 255 are the extended ASCII codes.
. The space character is the 33rd value, followed by punctuations, digits, uppercase characters
and lowercase characters.
. It is imPortant to note that digit characters have code values that differ from their numeric
equivalents: the code value of '0' is 48, that of 'l'is 49, that of '2' is 50, and so forth.
. For example, 32 is the ASCII code for a space. So the binary value for a space is 0100000 (i.e.
32 converted to binary).
. The word Five in ASCII is represented as 006 105 lr8 l0l since 006 representsF, 105
represents i, I l8 represents v and l0l represents e. This will translate to 00000110 0t l0l00l
0l110110 0l100101 in binary.
. It is imPortant to note that "l20" is treated as 3 characters in ASCII, which is diferent to the
number 358.

Advantages of using ASCII


. It uses the English language and can hold all the alphanumeric characters
. It uses less space than Unicode because it doesnt have many characters
. It has a "free" bit which can be used for error detection during data transmission.
. Most comPuters use ASCII codes, which makes it possible to transfer data from one computer
to another.

Disadvantages of using ASCII


. It only makes use ofthe English language.
. ASCII does not display characters read from a UNICODE document correctly.

r\r

50
ISCII Ctarl'cter ISGII Gtr:lcta IS{III Chr.rectc
vrlu3 veluc vrlue
000 -! olt:t + 086 Y
001
.E
o4 ol,it t
002 048 088 I
003 046 08e Y
004
.E
o47 I 090 z
006 044 0 091 T
006 o49 t ocz \
007 060 2 o05
008 .H 051 s 09+ l
@0 .I 052 4 095
010 05:i 6 006
011 0t4 6 O'T I
072 o5E 7 094 b
013 056 s 00e c
014 O57 I 100 d
016 164 101 I
016 .P 069 i 102 f
017 'e 060 105 E
018 061 : 10,4 t
019 osz > 105 i
m0 063 ? 106 j
ut7 -u o6+ o 707 L,
.Y
utz 066 I 109 l-
023 -9 0e6 E 109 !
o24 .I ott c 110 ! l

025 068 xt 111 o


m6 06e E 77?
' o27 't
.\
070 F 113
P
q
mg 071 o 174 r I

vza o72 s
ut0 :l 0?3 I
118
110
I
t
031 o74 J 777 u
032 I+ecal 076 I 113 Y
0t I 076 T, 119 I
034 o77 t{ 720 r
036 I 078 I 727 I
ogs t 07/, 0 722 z
037 t oso P 123 t
oit8 t oa1 e 724 I
099 08il B 726
040 ( ost s 126 \
041 ) ogt T 727 IIEL
&2 l oa5 u

Binary Coded Decimal (BCD)


. BcD is used to represent some numbers that are not proper numbers (numbers that dont
behave like actual numbers), for example, barcode numbers.

5l
BCD is used by digital voltmeters, frequency converters and digital clock" to display outpu:
information in decimal.
In BCD, each decimal digit is simply changed into a four-bit binary number ' hich are ther
placed one after another in order.
The following shows decimal digits in BCD:

0 0000
I 0001
7 0010
3 001I
4 0100
5 0101
6 0ll0
7 0lll
8 1000
9 1001

. The decimal number 41 is coded as 0100 0001


. The decimal number 9212 is thus coded as l00l 0010 0001 00102 in BCD'

Advantages ofusing BCD


. It is easy to convert a number from BCD to decimal form and vice versa'
. It is also simple to implement a hardware algorithm for the BCD converter.
. It is usefirl in digital iystems whenever decimal information is given either as irtDut or dis-
played as output.

Disadvantages of using BCD


. BCDiode for a given decimal number requires more bits than the straight binary code and
hence there is didcdty in representing the BCD form in high speed digital computers
in arith-
metic oPerations.
. rhe speed of the arithmetic operations that can be realised using BCD code is naturally slow
due to the complex hardware circuitry involved'
. and Logic
The arithmetic operations using BCD code require a complex design of Arithmetic
Unit (ALU) than the straight binary number system

For example, adding I and 19


(1) 0000 0001a
+(19) 0001 l00lz
0001 l0l0z

The first wrong and 1010 does not exist in BCD. The error is caused by the range ofnumbers
digit, I is
However, the \
used for representing data in BCD. BCD uses 4 bits which is 2a = 16 combinations.
than 9 then 5 has
,rroi^o^ r"rrg. of riumbers that can be represented is 9. If the sum of bit is greater
(0110) gives us 0010 00002'
to be added tolhe result. Thus adding the result above,0001 10102 to 6
which is 20 in BCD.

52
I

Extended Binary Coded Decimal Interchange Code (EBCDIC)


The Extended Binary Coded Decimal Interchange Code (EBCDIC) uses 8 bits (4 bits for zone,
4 bits for digit) to represent a symbol in the data.
EBCDIC represents 256 characters, that is,28 = 256 different combinations.
It represents decimal numbers (0-9), lower case letters (a-z), uppercase letters (A-Z), Special
characters, and Control characters (printable and non-printable e.g. for cursor movement,
printer vertical spacing etc.).
EBCDIC codes are mainly used in the mainframe and mini computers.

Advantages of using EBCDIC


. An eight-bit code, thus having a total of256 diferent combinations.
. Code words are all ofequal length so they are relatively easy to decode.
Disadvantages of using EBCDIC
. Unlike ASCII, there is no "fred'bit which can be used for error detection. Ifa computer using
this code for internal representation is to be connected to a data transmission system, the data
will generally have to be converted to ASCII before transmission.

Unicode
. Unicode is enough to represent around 120,000 diferent characters in any language, English'
Chinese and even hieroglyphics.
. Unicode is a universal character encoding standard for the rePresentation ofletters, numbers
and symbols.
. Unicode uses 8 bits, 16 bits, 24 bits or 32 bits to represent a character.
. Each character is assigned a unique numeric value tlat applies across different platforms and
Programs.
. The most widely used Unicode encoding schemes are called UTF-8, UTF-16, and UTF-32.
. LrTF-16 is a variable length which uses 16 bits or 32 bits whereas UTF-32 is a fixed lengh
which uses 32 bits.
. UTF-8 is commonly used and it is a variable length as it contains either 8, 76,24 or 32 bits for
a character.
. UTF-8 characters with a lower Unicode number require fewer bits for their rePresentation
than those with a higher Unicode number.
. Using UTF-8, the character 2 has a decimal value 50 and bin'ary rePresentation of00ll00l0
wherias the Chinese character is represented by a Unicode number 35987 which translates
to I I101000 l0l10010 10010011 in binary.
. Most Microsoft Software and Linux distributions use Unicode.

Advantages of using UNICODE


. It can store characters from more than one language
. It can store characters from languages with more than 250 characters
. Unicode is almost universally accepted by computing platforms, browsers, and mobile devices
. Unicode can be used to represent "emojis". "Emojis" are those little characters such as a "smiling
face with an open moutH" a "small hand with a thump up' etc. that are used on Facebook or
Whatsapp.

53
Disadvantages of using UNICODE

' unicode uses a lot more space than AscII.


It takes 2 bytes to store each character.
Activity 12
t.., Represent the following decimal numhers in BCD:
(i) s67
(ir) 2t

Using the ASCII table, determine the


binary equivalence of the
?;, following characters:
(ii) 7
(iii) &

Representation
1:.
(i) Data.
the following in ASCII:
(ii) Abyte.

54
Revision

l. Calculate the number of bytes found in the following:


a) 2 KilobYte (Kb)
b) 3 MegabYte (Mb)
c) 4 Gigabyte (Gb)
d) s Terabyte (Tb) t8l

2. Perform the following binary arithmetic calculations:


a) l0l0 / l0
b) loto / ll
c) l0.lI / .010
d) lll00- 1101
e) llll00+ lll0l + 10001
O 1010ll x 110
g) 101.1x l.0l
h) 1tl.0ll x0'1r ll5l

3. Convert the following decimal values to binary using two's complement:


a) -92 b) 16 c) l0 d) -123 t8l

4. Round offthe following binary numbers to 3 significant figures:


a) lll0 b) l10l l2l
has occurred'
5. perform the following binary arithmetic and indicate whether an overflow

(i) ollo + oool


(ii) 0100 + 0001
(iii) 01ll + 0001
(iv) 0ll0+ l00l
(v) 1000 + 0001
(vi) ll00+ ll00 tr2l

6.Thesumof2.3gandl.4gSistobeworkedusingonly3significantfigures.Findtheactualerror
and relative error iftruncation is used'
t6l

7. Convert the following denary numbers to (i) octal


(ii) hexadecimal
a) s6 b) 78 c)108
t6l

8. Convert the following binary numbers to decimal


a) 1010
b) l1.0o0l
b) ll.lt
t6l
55
9. Convert the following denary numbers to binary
(i) 34s
(it 2s.s7s
(iii) 0.25
t6l
10. a) Using an apProPriate number ofbltes in each case' express the number 103r0 in:
(i) binarY
(it BCD t4l
be expressed in
b) Using the answer obtained in part (a) show how l03ro can
(i) octal
iii) hexaaecimal with a minimum amount of calculation' t8l

1l'a)outlinetwoadvantagesofrepresentingnumbersin2scomplementoverlscomplement.t?l
subtract 00ll0z from l01l 12 using
b) Assuming that we are working with signed five-bit numbers'
the twot comPlement rePresentation. l2i
to
.i errrr_irrg signed twot complement representation, find the decimal value corresponding
"
0lll0z and 101102.. I2l
represented in
12. a) Using a single byte for each answer, explain how the denary number -29 can be
binary in
(i)
sign and magnitude
(iii)
I's comPlement
(ii) 2's comPlement t5l
t4l
b) (i) Convert -54 and - 104 into 2's complement' 8 bit' binary numbers'
(ii) Add the binary values obtained in bXi) together' l2l
(iii) Co--.t t on the result that you obtained in bXii)' l2l

13.Floating-pointnumbersinaparticularcomputersystem'arestoredusing12bits.Thefirst5bitsare
set of 6 bits is used to store the exponent'
used for th"e stor"ge ofth" mantissa and the second
a) Using the repreientation above to help you' write
the number
(i) 8.s
ili) -+.s " no"ting-Point number in normalised foim' t6l
", that 8 bits are used for the
iiil sl<pl"t" the efiicts of changing the rePresentation so l2l
mantissa and 4 bits for the exponent.

14'Thedenarynumber-19%istoberePresentedasafloatingpointbinarynumbellsing12bits.The
for the exponent'
irst S bits b. used for the mantissa and the remaining four bits are to be used
"r"io what is meant by the mantissa and exponent of a floating point nlmber' l2l
a. Explain number' t6l
b. Represent the denary number as a normalised floating point binarybinary floating point rep-
I I I 0 as its
.. Ci* the denary number which would have 01000000 -\
for the exponent.
resentation if8 bits are used for the mantissa and 4 bits
t4l
d'Explainwhyitisnotpossibletorepresentzeroasanormalisedfloatingpointnumber.[2]
56
l5' using 8 bits for the mantissa and 6 bits for the exponent, normalise
the following 2s complement
binary numbers:
a) I l0l l0.l l2
b) 0llllll02
c) 0.00010102
t6j
l6',Normalise. the following floating point binary numbers.
The first g bits are used for the Mantissa
and the last 4 bits are used for the exponent.
a) 00011101 0ll0
b) 11000001 1l0l
c) lll0l0l0 0010
lel
17. a) Explain the following character sets,
i) Asclr
ii) BcD
iii) Unicode
iv) EBCDIC
b)For the above character sets, state one advantage and one disadvantage t8l
ofeach. I8l

}-

You might also like