Introduction to Computer Systems
Tutorial 01 - Data Representation
Week 2
Preparation Exercises [1 mark]
Complete the following questions on a separate sheet of paper, with your
name and student number clearly written. Please ensure your writing is
legible. Hand in to your tutor at the beginning of your tutorial /
laboratory session.
- How many different values can be represented in a 4-bit word? An
8-bit word? A 16-bit word? In a 32-bit word?
What range of unsigned integers can be stored in each of these words?
What range of two's complement numbers can be stored in each of these words?
Please give all your answers (except for the 32 bit words) as decimal numbers.
- Convert the following numbers to decimal:
- 768
- B1116
- 1010102 as an UNSIGNED integer.
This means we are only considering positive binary integers from
000001 to 1111112.
- 1011102 as a SIGNED integer.
This means we are using two's complement numbers with 000001 to
011111 representing positive numbers and 111111 to 100000 representing
negative numbers.
(as will be discussed, the C language supports both signed and unsigned
integers)
- What is the unsigned binary representation of 231
10?
Convert the result from binary to octal. How many binary digits make up
each octal digit?
Convert the binary value to hexadecimal. How many binary digits make up
each hexadecimal digit?
Tutorial Exercises [4 marks]
After an introduction of the class and going through solutions to the
preparation exercises, work through the following questions in your session.
Finish any uncompleted exercises for homework.
- Assuming unsigned numbers, what are the results of the following
binary additions / subtractions? (give the result in binary)
| 0101 00112 + |
0101 00112 - |
| 0110 11102 |
0001 01012 |
- Now assume that ALL numbers in Question 1 are in two's complement
form. Try to work out all results from Question 1 using binary
arithmetic. Then convert the numbers and results to decimal. Are the
results correct? If not, explain why not.
- What are the octal representations of the
following numbers? Hint: you might find it easier to first translate
to binary.
011 110 101 010 0112
1001 0111 1111 00012
AE3C9F16
301232214
- One byte is defined as 8 bits. Can the value from Preparation
Exercise 3, (i.e. 23110) be represented as an unsigned
integer in a single byte?
Can the value be represented as a two's complement number in a single
byte? Explain your answer.
- Represent the number -1.125 as an IEEE single precision
floating-point number.
- What are the decimal values of the following IEEE single precision
floating point numbers whose bit patterns are represented by the
following hexadecimal numbers.
42E4800016 3F88000016
- Can all numbers that can be represented by a finite fractional
decimal value be exactly represented using a finite number of binary
digits? Concisely substantiate your claim.
- Suppose we had an integer array of length 256, and the size of
an integer is 4 bytes. How many such arrays could fit into an
8 KB area of memory? Hint: express all quantities as powers of two.
Homework!
- Repeat Questions 1 and 2 above for the following:
| 0001 00012 + |
1010 10112 - |
| 1101 00112 |
1001 01102 |
-
Represent pi (=3.142) as an IEEE single precision floating-point
number.