[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: NaN encodings
On Mar 25, 2009, at 7:00 AM, Michel Hack wrote:
Earlier I wrote of x87 handling of NaNs and its pseudo-NaNs. I found
out a bit more: as of the 80486 pseudo-NaNs raise the Invalid
Operation
exception and are replaced with the default QNaN if the exception is
masked. So the p-2 rule continues to apply.
Michel.
Sent: 2009-03-25 14:03:48 UTC
That sounds correct. The x87 encoding has several unsupported encodings:
pseudo-NaNs, pseudo-Infinities, and unorms (unnormalized numbers).
All of these are treated as unsupported, which is a sort of super-NaN:
raising invalid and returning the so called Real Indefinite QNaN.
(There are a few exceptions for operations that are interpreted as
operating
directly on the bits such as change sign, absolute value, and 80-bit
load and store
operations).
The other strange case in x87 is when the exponent is 0 the fraction
is non-zero,
but the leading bit of the significand is set. These are psudo-denormals
and are treated as though the exponent were written with a 1.
Operations that consume pseudo-denormals raise the D flag (for
denormalized input).
So these are a funny case where (x+0.0) can change the encoding (but
not the value)
of x, if x is a pseudo-denormal.
Fortunately, the only way to get a pseudo-denormal (or one of the
unsupported formats for that matter)
is from an 80-bit load from memory, so in typical operation they would
only arise
from reading 80-bit data from the wrong address, or otherwise
improperly initialized data.
Jeff
PS If you are trying to figure out why these strange things aren't
just converted when loaded,
there was a time when an 80-bit load followed by an 80-bit store was
the fast way to move
10 bytes of data.