Java Reference
In-Depth Information
Note that overflow is always abrupt (also called a sudden overflow ).
Because of the limitations in the representation of real numbers there are
no provisions for gradual overflow. The result of the overflow of a posi-
tive number results in + or in the larger representable positive real,
while the overflow of a negative number results in - or in the smallest
representable negative real. Which action is taken depends on the se-
lected rounding mode.
Underflow exception
Overflow conditions take place as the absolute value of a number becomes
very large. Underflow, on the other hand, takes place as the absolute value
of a number becomes very small, in other words, as its value approximates
zero. One method of handling numbers that approximate zero is to make
them equal zero. This operation, sometimes called flush to zero , has been
frequently used as a simple solution to the problem of underflow. But this
sudden underflow presents some peculiar problems.For example, in the
equation
(x-y)+y = x
if y is a sufficiently large number, then the portion ( x-y ) could suddenly
underflow to zero.
According to the provisions of IEEE 754, overflow conditions are han-
dled by abruptly converting the result to an infinity, or to the largest rep-
resentable real. Which method is adopted depends on the rounding mode
in effect. In order to avoid the dangers of sudden underflow, the standard
requires using a special un-normalized representation of real numbers,
called denormals .
To understand gradual underflow you must recall that a floating-point
representation is said to be normalized when the first digit of the
significand is non-zero. Normalization is designed to preserve the maxi-
mum number of significand digits and the precision of the stored value.
You can deduce that the smallest representable number in either format
is encoded with an exponent pattern of 00...01B and a significand of
00...00B. Gradual underflow is based on the use of a special encoding for
real numbers (the so-called denormals) which are characterized by an ex-
ponent in the form 00...00B and a denormalized significand. This repre-
sentation, easily identified by an exponent containing all zero bits, allows
representing numbers smaller than the smallest one that could be en-
coded using a normalized significand. Gradual underflow is made possi-
ble at the expense of precision. As the significand becomes denormalized,
the number of its significant digits diminishes.
Search WWH ::




Custom Search