Defining IEEE NaN and Inf at compile time

Nelson H.F. Beebe validgh!uunet!math.utah.edu!beebeaSun.COM
Tue Dec 18 14:56:39 PST 1990


Recent experiments on Sun, Stardent, and HP-9000 BSD systems
(all with IEEE 754 arithmetic) show that Fortran code like

	real NaN
	parameter (NaN = 0.0/0.0)

or
	real Inf
	parameter (Inf = 1.0/0.0)

will not compile; compilers give messages like ``Error: data
value too large''.

A non-portable architecture- and compiler-dependent version like

	real NaN
	parameter (NaN = z'7fffffff')

is however accepted.

Curiously, on the 3 systems I tried, I got only a warning from 

	real NaN
	NaN = 0.0/0.0

Now that IEEE 754 arithmetic is becoming widely available, it
seems to me that one ought to be able to use it, such as in the
parameter statements of the type described above.

Naturally, this applies equally well to C as to Fortran.

I would like to invite comment on this: should compile-time
evaluation of Infinity and Not-a-Number terminate compilation,
or not?


========================================================================
Nelson H.F. Beebe
Center for Scientific Computing
Department of Mathematics
220 South Physics Building
University of Utah
Salt Lake City, UT 84112
 Tel: (801) 581-5254
 FAX: (801) 581-4148
 Internet: beebeamath.utah.edu
========================================================================



More information about the Numeric-interest mailing list