[comp.lang.fortran] How to detect "NaN" in ANSI FORTRAN 77

hsong@nvuxl.UUCP (g hugh song) (12/28/90)

Why is there no way to detect "NaN" status in ANSI FORTRAN 77?

I am having a terrible time wrestling with my program.

I finally found that the bug could be found if there were a mechanism which
finds floating point exception "NaN"---yeah! The famous "NaN"---which is
*allowed* to be *undetected* by ANSI FORTRAN 77 Standard.  Am I correct?
It seems that the MIPS f77 compiler which is used by DEC in their DecStations.
does not have floating-point-exception detection mechanism
in accordance with ANSI FORTRAN 77 Standard.   Arrrrgggg....
I do not understand why ANSI did not specify such mechanism.
If you know why, please enlighten me.   Is this kind of thing specified in
FORTRAN 9x?

I know a lot of compiler vendors implemented such detection meachanism
in their product.

Thanks.

	-hsong-
	nvuxl!hsong@bellcore.bellcore.com

PS: You need to type "nvuxl\!hsong@..." on Csh command line.

khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup) (12/28/90)

In article <763@nvuxl.UUCP> hsong@nvuxl.UUCP (g hugh song) writes:

   Why is there no way to detect "NaN" status in ANSI FORTRAN 77?

Well, for starters there was no IEEE 754 back then.

   I finally found that the bug could be found if there were a mechanism which
   finds floating point exception "NaN"---yeah! The famous "NaN"---which is
   *allowed* to be *undetected* by ANSI FORTRAN 77 Standard.  Am I correct?

IEEE 754 default mode is to not trap on "exceptions", however
exception handling is under user control. On Suns, for example,
ieee_handler("set","common",%val(2)) would have done the trick. I am
sure there is something nearly equally simple on your decstation.

   If you know why, please enlighten me.   Is this kind of thing specified in
   FORTRAN 9x?

Alas no. Language committees still mostly punt on FP issues. There is
a "languague compatible floating point" standard working its way
through ANSI; however it was cleverly crafted to permit all the sins
that IEEE 754 outlawed, so I don't think it will be terribly useful.

--
----------------------------------------------------------------
Keith H. Bierman    kbierman@Eng.Sun.COM | khb@chiba.Eng.Sun.COM
SMI 2550 Garcia 12-33			 | (415 336 2648)   
    Mountain View, CA 94043