Unit 4
Data Representation in Computers



e.g. denary 751

binary

1

0

1

1

1

0

1

1

1

1

hex

2

E

F

oct

1

3

5

7



Two's complement

Copy digits from the LSB towards the MSB, up to and including the first "1" digit and then invert the rest.

5

0

0

0

0

0

1

0

1

-5

1

1

1

1

1

0

1

1


14

0

0

0

0

1

1

1

0

-14

1

1

1

1

0

0

1

0



OR add one to the one's complement

e.g.

5

=

0

0

0

0

0

1

0

1


   

1

1

1

1

1

0

1

0

 

+

0

0

0

0

0

0

0

1

-5

 

1

1

1

1

1

0

1

1




Fixed point notation

e.g. (taking radix point between 4th and 5th bits)

5CHEX

=

0

1

0

1

1

1

0

0

=

+

5¾



Floating point

MANTISSA

EXPONENT

-1

1/2

1/4

1/8

1/16

-4

2

1

               

^
radix point

           


e.g.

73HEX

=

0

1

1

1

0

0

1

1

   

^

           
 

=

7/8 x 23

=

7

     


Normalisation

In normalised form the first two bits are distinct

Overflow - when a number is too large for the exponent to be expressed (positive exponent)

Underflow - when a number is too near zero for the exponent to be expressed (negative exponent)


e.g. normalise:

 

0

0

0

0

1

1

0

1

0

1

 

0

0

0

0

1

0

 

=

0

0

0

0

1

1

0

1

0

1

 

Exponent = 2

   

^

                             
 

=

0

1

1

0

1

0

1

0

0

0

 

Exponent = 2 - 3

   

^

                             
 

=

0

1

1

0

1

0

1

0

0

0

 

1

1

1

1

1

1

   

^

                             


Adding two normalised floating point numbers

  1. Unnormalise largest (exponent) and make exponents the same
  2. Add mantissa (keep exponents)
  3. Normalise

e.g.

2.6 x 102

+

8.9 x 103

=

2.6 x 102

+

89 x 102

=

91.6 x 102

 

=

9.16 x 103

 


Multiplying two normalised floating point numbers

  1. Multiply mantissas
  2. Add exponents
  3. Normalise

e.g.

2.6 x 102

x

8.9 x 103

=

23.14 x 105

 

=

2.314 x 106