CPSC 120 Practice Exercises

Representation of Integers

 

 

1.  Convert each of the following numbers from the given base to base 10.

 

(a)  1000112

(b)  10111000102

(c)  45318

(d)  B32F16

(e)  4221305

 

2.  Convert each of the following base 2 numbers to base 8 (octal) and base 16 (hexadecimal):

 

(a)  100110111

(b)  10111011110101

 

 

3.  Convert the octal number 74038 to

(a) binary

(b) hexadecimal

 

4.  Convert the hexadecimal number  3C9E716  to

(a) binary

(b) octal

 

5.  Convert the following base 10 numbers to binary, octal, hexadecimal, and base 7. 

 

(a) 528

(b) 4269

(c) 341

 

6.  Determine the largest positive integer that can be stored in a word for each of the following word sizes.  Assume the word will store signed integers.

 

(a) 6 bits           (b) 12 bits         (c) 32 bits

 

 

7.  Find the two’s complement representation of each of the following integers.  Assume a 16-bit representation:  (a)    –198      (b)    37       (c)   – 37     (d)  – 5,235      (e)  9,102  (f)  – 9,102

 

 

8.  Suppose each of the following bit patterns is an integer represented in 8-bit two's complement.  Find the base 10 value of each.

 

(a)    01110011      (b)    10001001      (c)   11011110     (d)  00000111     (e)  11111111