In: Computer Science
4.4-4.6 The term arithmetic overflow refers to
the condition where the result of some computation is
outside the range of expected results. When a computation produces
a result with absolute value
smaller then the computer can represent we have arithmetic
underflow.
Answer the following 4 point questions regarding the detection of
incorrect computations when processing ALU instructions.
4.4 We have explored the potential for incorrect
answers caused by overflow when the ALU operates
on integers. For completeness, we need to examine the possibility
of underflow in integer ALU
operations. Either give an example of underflow or explain why
underflow is impossible for
integer ALU computations.
4.5 Can floating point arithmetic using the
IEEE standard format result in overflow? Either explain
why overflow is impossible for floating point or explain how the
presence of overflow can be
detected. Note: an example can be used when giving your answer, but
an example without
explanation is too poor to afford full credit.
4.6 Can floating point arithmetic using the
IEEE standard format result in underflow? Either explain
why underflow is impossible for floating point computations or
explain how the presence of underflow can be detected. Give an
example with an explanation.
4.4
Arithmetic underflow is the condition in a computer program where the result of a calculation is a number of smaller absolute value than the computer can actually represent in memory on its central processing unit.
An example of this condition would be:-
When the true result of a floating point operation is smaller in magnitude (that is, closer to zero) than the smallest value representable as a normal floating point number in the target datatype.
It is impossible in integer ALU instruction because there are no decimals and no value really close to 0 (just 1 and -1).
4.5
Yes, overflow can happen using IEEE standards too but in this case, it will not terminate the program. It'll result in producing an exception.
According to IEEE 754, if the absolute value of the rounded value is too large to be represented, an infinity or maximal finite value is returned, depending on which rounding is used.
For example, if the number to be represented is 10000 but the maximum limit is 8191(213-1), then it will show 8191.
4.6
If the rounded value is tiny (as specified in IEEE 754) and inexact (or maybe limited to if it has denormalization loss, as per the 1984 version of IEEE 754), returning a subnormal value including the zeros, an underflow exception will be thrown.
The underflow condition only arises if there is also a loss of precision in the resulting value.
The default handling in IEEE 754 for underflow (as well as other exceptions) is to record as a floating point status that underflow has occurred. This is specified for the application-programming level, but often also interpreted as how to handle it at the hardware level.
Hence, it's presence can be detected if there's a loss of precision in the value or a value of exact zero(decimals too) is returned.