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

Re: Payload length and interpretation in IEEE Std 754-2008

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 

"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

754 | revision | FAQ | references | list archive