5010.   I have just built a new machine. It uses a 6-bit character set, which I have grouped together as something I call a ‘snack’. Other than that, the lay-out of data types cor­responds to traditional machine architecture. It uses two’s compliment for negative values. Characters will require 1 snack of storage of per character: given the 6-bits, standard character set will use 1-bit for parity; the extended character set will use all 6-bits of the snack). An integer will use two snacks, of which 1-bit (the left-most bit) will be used to represent the sign. Longs will have twice the storage of integers. Reals (floats) will use 4 snacks: 1-bit for the sign, 8-bits for the characteristic of the exponent, and the remainder for the mantissa.

 

 

a.         How many characters can I represent with a standard meal character set?

 

Given 6-bits, with 1-bit being used for parity, there are a total of 25 = 32 characters available

 

b.         What is the range of a signed integer?

 

Given 2 * 6-bits = 12-bits, with 1-bit being used for the sign, The range is -211 to +211 – 1 = -2,048 to +2,047

 

c.         What is the largest unsigned long I can have? (the formula alone is OK)

 

Given 4 * 6-bits = 24-bits, the largest long integer is 224  1 = 16,777,216

 

d.         What Level of precision will real numbers (floats) have?

 

Given 4 * 6-bits = 24-bits, minus 1 for the sign and minus 8 for the characteristic of the exponent, I have 15 bits for the mantissa. 215  = 32,768 which means I can represent ALL 4 digit numbers (and some 5 digit numbers)

 

e.         Using my snack machine, I issued the command:    int a = -38;

            Show EXACTLY how this will be stored in RAM in my new machine.

 

38/2 = 19         38 % 2 = 0

19/9 = 8     19 % 2 = 1

8/2 = 4         8 % 2 = 0

4/2 = 2         4 % 2 = 0

2/2 = 1         2 % 2 = 0

1/2 = 0         1 % 2 = 1

 

Collecting from bottom to top, we find that 3810 = 1000102

 

However, on my machine, 12-bits, this would be stored as:

 

000000100010

 

This becomes:

 

111111011101 (one’s compliment)

+                    1

111111011110 (two’s compliment)