Forgot which way the "signaling-vs.-quiet" thing went. |
For binary formats, in all three cases under consideration, the exponent field is all-bits-on.
Infinity has all zeroes in the trailing significand field.
Quiet NaN has a 1 in the leading bit of the trailing significand field; the remainder of that field is the payload defined by the implementor.
Signaling NaN has a 0 in the leading bit of the trailing significand field; the remainder of that field is the payload defined by the implementor.
What's the distinction, then, between a canonic infinity in that representation and a *signaling* NaN with a payload of zero?
Is there a specification somewhere that says that the payload may not be zero?
> Subject: Re: Payload length and interpretation in IEEE Std 754-2008
> From: scanon@xxxxxxxxx
> Date: Fri, 29 Apr 2011 10:12:27 -0700
> CC: forieee@xxxxxxxxxxxxxx; stds-754@xxxxxxxxxxxxxxxxx; bobkarlin@xxxxxxxxxxxxxxxxx; wmklein@xxxxxxxxxxxxx
> To: charles.stevens@xxxxxxxx
> On Apr 29, 2011, at 10:01 AM, Charles Stevens wrote:
> > The way the COBOL rules are stated now, the result of this action is a positive quiet NaN with a payload of ZERO. The payload might or might not be modified later.
> > What I have since realized is that the bit-pattern that results, in a BINARY interchange format (but not a DECIMAL format), is exactly the same as that of a positive infinity. We have "class tests" for the two infinities and for a NaN, and COBOL doesn't "do" infinity arithmetic, so all three are considered non-numeric in COBOL rules.
> If you're following the IEEE-754 recommended practice, the resulting bit pattern is *not* a positive infinity. In particular, you say "the result of this action is a positive *quiet* NaN with a payload of ZERO". Clause 6.2.1 reads:
> "A quiet NaN bit string should be encoded with the first bit (d1) of the trailing significand field T being 1."
> So, if you follow the recommended practice, your "quiet NaN with a payload of ZERO" looks like this:
> sign: 0
> exponent: 111…11
> significand: 100….00
> and does not have the same encoding as positive infinity. To be fair, this is recommended, not required, and COBOL does not need to follow this convention. But it would be wise to do so.
> - Steve