Logout

4.1.4 Discuss the advantages and disadvantages of integer and floating-point representations.

(No teaching notes for this one.)

Sample Question:

(h) Outline an example of a computer application that would need to store floating
point values rather than integer values. Clearly state why errors in representation
would cause problems. [3 marks]

 


JSR Notes:

Read through carefully the short, but adequate section in the textbook on page 227.

The point of this assessment statement is, I think, to get you thinking critically about both of these number formats; not just blindly using them.  But ultimately your understanding is to come down to being able to discuss advantages and disadvantages of both systems.

So thinking a bit more deeply about integers, but also about their relative advantages and disadvantages, their most obvious disadvantage is that they cannot represent fractional portions.  But the advantage is that they are able to represent every single value within their range.  If a the byte type, in its non-signed form can represent all integer values between 0 and 255, then it can represent all of those integer values, full stop.

Compare this to any real number representation on a computer; it cannot represent all of the values between, for example, -32.9375 and 31.9375.  In fact there are infinite values between these two that it cannot represent; take for example -32.9374, or -32.93751.

But, the main advantage of a floating point representation is that it can indeed represent at least some fractional portions of numbers, which integers cannot do.

In terms of the textbooks statement of “floating point representation greatly expands the range of numbers that can be represented”, consider this: if we have 32 bits, we have around 4 billion combinations of 0s and 1s; that doesn’t change whether using them for integer or for floating point representations.  But it is also true that, even though there are distinct gaps between the values possible to be represented by floating point, their range, when considering precision as well as largest and smallest, is certainly more than that of integer values.

And, in terms of the limitations of the combinations of 0s and 1spossible, both integer or floating point can experience overflow errors, and floating point can experience underflow errors – but that’s something that is just not within the realm of possibility of integers.

As always, think about all of this in combination with what is in the textbook, and anything additional discussed in class.