Printing NaN with SP edit descriptor 
Author Message
 Printing NaN with SP edit descriptor

When printing a "not-a-number" value with the SP edit descriptor in
force, I found that one compiler prints +NaN and another prints NaN.
Both compilers claim to be IEEE-compliant. Which is right? Or are both
outputs OK?

John Harper



Tue, 06 Sep 2011 10:23:34 GMT  
 Printing NaN with SP edit descriptor

Quote:
> When printing a "not-a-number" value with the SP edit descriptor in
> force, I found that one compiler prints +NaN and another prints NaN.
> Both compilers claim to be IEEE-compliant. Which is right? Or are both
> outputs OK?

> John Harper

The 2008 edition of IEEE Std. 754 allows either form.
The fortran 2003 standard requires the output not to
have the leading sign.  Neither the 1985 version of
IEEE Std. 754 nor Fortran standards before Fortran 2003
address the issue.

Bob Corbett



Tue, 06 Sep 2011 12:50:50 GMT  
 Printing NaN with SP edit descriptor

Quote:


>> When printing a "not-a-number" value with the SP edit descriptor in
>> force, I found that one compiler prints +NaN and another prints NaN.
>> Both compilers claim to be IEEE-compliant. Which is right? Or are both
>> outputs OK?
> The 2008 edition of IEEE Std. 754 allows either form.
> The Fortran 2003 standard requires the output not to
> have the leading sign.  Neither the 1985 version of
> IEEE Std. 754 nor Fortran standards before Fortran 2003
> address the issue.

For numeric output Fortran 2003 seems to allow a '+'.
Interesting that it isn't allowed for NaN output.

It seems that a sign is allowed for NaN input.
(It says sign, and doesn't seem to restrict the sign
to negative.)

-- glen



Tue, 06 Sep 2011 14:53:27 GMT  
 Printing NaN with SP edit descriptor


Quote:


>>> When printing a "not-a-number" value with the SP edit descriptor in
>>> force, I found that one compiler prints +NaN and another prints NaN.
>>> Both compilers claim to be IEEE-compliant. Which is right? Or are both
>>> outputs OK?

>> The 2008 edition of IEEE Std. 754 allows either form.
>> The Fortran 2003 standard requires the output not to
>> have the leading sign.  Neither the 1985 version of
>> IEEE Std. 754 nor Fortran standards before Fortran 2003
>> address the issue.

>For numeric output Fortran 2003 seems to allow a '+'.
>Interesting that it isn't allowed for NaN output.

>It seems that a sign is allowed for NaN input.
>(It says sign, and doesn't seem to restrict the sign
>to negative.)

I can fill in some of the irrationale for that change, though I don't
know in what form it reached Fortran.

IEEE 754 is explicit that the sign bit conveys no meaning for NaNs,
and implies that it should be ignored.  C99 decided to give it some
'meaning', in the sense that it is used to change the value of some
expressions but is still set unpredictably.  Heaven help us, IEEE 754R
followed C99 (the first paragraph of 8.3, if anyone is interested) ....

Given that fiasco, what should Fortran do?

As I am saying increasingly often about standards, one can laugh, cry
or scream, to taste.

Regards,
Nick Maclaren.



Tue, 06 Sep 2011 15:29:25 GMT  
 Printing NaN with SP edit descriptor

Quote:

> > When printing a "not-a-number" value with the SP edit descriptor in
> > force, I found that one compiler prints +NaN and another prints NaN.
> > Both compilers claim to be IEEE-compliant. Which is right? Or are both
> > outputs OK?

> > John Harper

> The 2008 edition of IEEE Std. 754 allows either form.
> The Fortran 2003 standard requires the output not to
> have the leading sign.  Neither the 1985 version of
> IEEE Std. 754 nor Fortran standards before Fortran 2003
> address the issue.

> Bob Corbett

When researching this issue in the light of Bob's helpful comment, I
found an error in the Fortran 2003 Handbook p.399 where Table 10-9
gives the effects of SP and SS sign edit descriptors the wrong way
round, because it says

SP The optional plus sign will not appear.
SS The optional plus sign will appear.

John Harper



Fri, 09 Sep 2011 05:35:12 GMT  
 Printing NaN with SP edit descriptor
Quote:



>>> When printing a "not-a-number" value with the SP edit descriptor in
>>> force, I found that one compiler prints +NaN and another prints NaN.
>>> Both compilers claim to be IEEE-compliant. Which is right? Or are both
>>> outputs OK?
>>> John Harper
>> The 2008 edition of IEEE Std. 754 allows either form.
>> The Fortran 2003 standard requires the output not to
>> have the leading sign.  Neither the 1985 version of
>> IEEE Std. 754 nor Fortran standards before Fortran 2003
>> address the issue.

>> Bob Corbett

> When researching this issue in the light of Bob's helpful comment, I
> found an error in the Fortran 2003 Handbook p.399 where Table 10-9
> gives the effects of SP and SS sign edit descriptors the wrong way
> round, because it says

> SP The optional plus sign will not appear.
> SS The optional plus sign will appear.

> John Harper

Thanks for spotting this.  We'll add it to the "mistakeo"
list.

Dick Hendrickson

PS:  I'll renew my offer of two free American Beers if you
every get up to Minneapolis.  Thanks for the careful reading.



Fri, 09 Sep 2011 07:25:05 GMT  
 Printing NaN with SP edit descriptor

Quote:


> > found an error in the Fortran 2003 Handbook p.399 where Table 10-9
> > gives the effects of SP and SS sign edit descriptors the wrong way
> > round,
> PS:  I'll renew my offer of two free American Beers if you
> every get up to Minneapolis.  Thanks for the careful reading.

Trying to scare him off of coming, eh? :-)

--
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain



Fri, 09 Sep 2011 07:56:24 GMT  
 Printing NaN with SP edit descriptor

Quote:

> "mistakeo" list.

Pun intended? I'm starting to lose[sic] count on puns and
meta-puns in clf in the last time.

--
Jugoslav
www.xeffort.com
Please reply to the newsgroup.
You can find my real e-mail on my home page above.



Fri, 09 Sep 2011 17:21:04 GMT  
 Printing NaN with SP edit descriptor
Quote:


>> "mistakeo" list.

> Pun intended? I'm starting to lose[sic] count on puns and
> meta-puns in clf in the last time.

Yes, I think of "typo", "mistakeo" and "thinko" as an
increasing series of unfortunate events.

Dick Hendrickson

Quote:
> --
> Jugoslav
> www.xeffort.com
> Please reply to the newsgroup.
> You can find my real e-mail on my home page above.



Fri, 09 Sep 2011 23:22:58 GMT  
 Printing NaN with SP edit descriptor

Quote:



> >> "mistakeo" list.

> > Pun intended? I'm starting to lo?se[sic] count on puns and
> > meta-puns in clf in the last time.

> Yes, I think of "typo", "mistakeo" and "thinko" as an
> increasing series of unfortunate events.

See also "braino" or the less polite (but common) variant "brain fart".
Those of us in the book-writing business tend to be familiar with all of
these. :-(

--
Richard Maine                    | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle           |  -- Mark Twain



Sat, 10 Sep 2011 00:02:28 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. SP edit descriptor

2. Real Editing w/ E edit descriptor question

3. writing characters using Z edit descriptors

4. T edit descriptor and ADVANCE="NO"

5. Question about edit descriptors

6. Q edit descriptor

7. F edit descriptor question

8. H EDIT DESCRIPTOR

9. tab edit descriptors and nonadvancing I/O

10. Q Edit Descriptor

11. converting format specifications with / edit descriptors to internal writes

12. P output edit descriptor

 

 
Powered by phpBB® Forum Software