Google
 
Site navigation: [ Home | Theory | Java | About ]

Example questions on computer maths

A control system is being designed for a washing machine using a 16-bit register to store data about the state of the machine, such as whether the door is open or closed, the level of water in the machine and the temperature selected for the wash (an integer).

How many bits are required to store the following data:

    1. The state of the door
    2. Whether the water level is ¼ full, ½ full or ¾ full
    3. The temperature range 0 to 75 degrees C 

[3 marks]

If the temperature can only be set at 5 degree intervals, from 25 to 75, how many bits are required to store the settings? 

[1 mark]

In another control system 9 bits are available to store a temperature range of -90 to plus 90 degrees. Show how this could be done using a floating point binary representation while maintaining the maximum possible precision.

[4 marks]

If the 9-bits were allocated to storing an integer in two's complement form, what would be the minimum and maximum value that could be stored (you may give your answer as a power of 2). 

[2 marks]

Assume there exists a hypothetical decimal computer that stores numbers in a word. A word which stores an integer value can hold eight symbols, one sign (+ or -) in the leftmost position and seven decimal digits. A word which stores a floating-point number can hold eight symbols but the word is divided into two parts. One part can hold three symbols. It is called the exponent and is composed of a sign and two decimal digits. It is located in the leftmost (high order) three positions. 

The second part which can hold five symbols is the mantissa. This part is composed of a sign and four decimal digits normalised to the most significant digit and is located in the rightmost (low order) five positions. The digits of the mantissa are normalised as indicated in the floating-point example (-2.73479) below.

Examples of integers and floating-point numbers are given below. 

-672

is represented as

-

0

0

0

0

6

7

2

-2.73479

is represented as

+

0

1

-

2

7

3

6

(a)   What is the smallest integer and the largest integer that can be stored?

[2 marks]

(b)   What is the largest floating-point number that can be stored? What is the smallest floating-point number greater than 0 that can be stored. In both cases give the answer as a power of 10.

[2 marks]

(c)  Given the range of available real values in this computer, copy and complete the real number line below. Indicate the range of negative and positive real values, underflow and overflow, by means of labels.

[8 marks]

Back to top

related: [ Topic 4 home | previous: errors ]

 


The site is partly financed by advertising revenue, partly by online teaching activities and partly by donations. If you or your organisation feel these resouces have been useful to you, please consider a donation, $9.95 is suggested.


Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy.

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.

© 2001 - 2007 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified on October 28, 2013