[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: question about underflow detection



Hi Liang-Kai:

You're running up against one of the dark corners of 754 that isn't fully specified.  IEEE-754 defines underflow to be signaled when the result is both tiny and inexact, and allows tininess to be detected either:

a)  after rounding—when a non-zero result computed as though the exponent range were unbounded would lie strictly between ± b^{emin}

or

b)  before rounding—when a non-zero result computed as though both the exponent range and the precision were unbounded would lie strictly between ± b^{emin}. 

In single precision, these two rules differ only on the intervals ±[0x0.ffffff8 * 2^{-126}, 0x1.0 * 2^{-126}).

Your first example falls outside of that range, and underflow is signaled using either rule.  Your second example, however, falls into the range in which the two rules differ: if tininess is detected after rounding, underflow is not signaled, whereas if tininess is detected before rounding, underflow is signaled.

- Steve

On Aug 22, 2011, at 12:34 PM, Liang-Kai Wang wrote:

Hi,

I have a question about how the standard raises underflow and would
like to see if somehow can help on this.

Here are the two cases (single precision multiply) I am trying to
reslve (assuming both use round tie to even)
1. 80ffffff x bf000000
Assuming we have unlimited precision and unbound exponent, we actually have
1.111_1111_1111_1111_1111_1111 * 2 ^ {-126} x 1.0 * 2 ^ {-1} =
1.111_1111_1111_1111_1111_1111 * 2 ^{-127}
Because the unbiased exponent is -127, it cannot be fit in the IEEE
format, and we need to right shift the mantissa by one bit to get
0.111_1111_1111_1111_1111_1111_1 * 2 ^{-126}

After rounding, we have 1.0 * 2 ^ {-126}

2. 807fffff x bf800001
0.111_1111_1111_1111_1111_1111 * 2 ^{-126} x
1.000_0000_0000_0000_0000_0001 * 2^{0} =
0.111_1111_1111_1111_1111_1111_1111_..._1 * 2 ^{-126}
After rounding, we have 1.0 * 2 ^ {-126} as well.

In both cases, should the underflow flag be raised based on the standard?

Liang-Kai


754 | revision | FAQ | references | list archive