ITC222 Solutions to Exercises 4


The solutions are to the exercises specified in the section Data representation of the Study Notes. The exercises are from Chapter 4 of the textbook, A Programmer's View of Computer Architecture by Goodman & Miller and some solutions are derived from those given in The Instructor's Manual by Miller.

Some of the exercises include material of general interest that goes beyond the requirements of this subject. These are indicated by an asterisk.


Exercise 4.2

  1. 32010 = 1 0100 00002
  2. 7010 = 100 01102
  3. 12810 = 1000 00002
  4. 3110 = 1 11112
  5. 2510 = 1 10012
  6. 8410 = 101 01002

Exercise 4.3

  1. 10 11102 = 4610
  2. 01012 = 510
  3. 11112 = 1510
  4. 1 0111 11012 = 38110
  5. 11 11112 = 6310
  6. 1010 10102 = 17010

Return to top of page

Exercise 4.4

Direct calculator conversion gives an error on most calculators here, so proceed by longhand calculation or as follows.

log2 4005 = 11.96..., so 12 bits are needed in an unsigned representation or 13 in a signed representation.


Exercise 4.5


Exercise 4.6

We need to know the representation being used (two's complement, unsigned, sign-magnitude).

Exercise 4.7

decimal 2's complement sign-magnitude 1's complement
-68 1011 1100 1100 0100 1011 1011
108 0110 1100 0110 1100 0110 1100
-120 1000 1000 1111 1000 1000 0111
-85 1010 1011 1101 0101 1010 1010
85 0101 0101 0101 0101 0101 0101
101 0110 0101 0110 0101 0110 0101
38 0010 0110 0010 0110 0010 0110
127 0111 1111 0111 1111 0111 1111
125 0111 1101 0111 1101 0111 1101
0 0000 0000 0000 0000 0000 0000

Return to top of page

Exercise 4.8

  1. 1111 1111 1010 1010
  2. 0000 0000 0101 0000
  3. 0000 0000 1111 1111
  4. 0000 0000 0111 1101
  5. 1000 0000 0111 1111
  6. 1111 1111 1010 1010

Exercise 4.9

The algorithm for converting a 16-bit sign-magnitude integer to an 8-bit sign magnitude integer, including check for validity is:
  1. Interchange bits 7 and 15 (numbering from 0 as the least significant bit);
  2. If the most significant byte is 0 remove it, otherwise the number does't fit in 8 bits;

Exercise 4.10

SAL allows integers in the 2's complement representation which range from 0x80000000 (-2147483648) to 0x7fffffff (2147483647).

Exercise 4.11

The algorithm for the binary to ascii conversion used in the solution is rather inelegant. This is because we haven't yet found out how to process arrays in memory. Consequently the ascii digits must be generated in order from most significant to least significant. A much better algorithm can be used for generating the digits in order from least significant to most significant.
Return to top of page

Exercise 4.12

Single precision IEEE FPS representation for -83.710:

Exercise 4.14

Additive inverse simply means the negative. Taking this operation twice gives the original number.
Return to top of page
Author: Ken Lodge
Last Update: 21 August, 1997

ITC222 Home Page