From: "A.Appleyard" To: djgpp AT sun DOT soe DOT clarkson DOT edu Date: Tue, 7 Feb 1995 09:34:38 GMT Subject: Re: How to use Inf and NaN? On Wed, 1 Feb 1995, Papp Istvan wrote: > I have a 486DX2-50 machine with MS DOS 6.22, and I use gcc 2.60. I'd like > to use Inf and NaN with djgpp as a regular number. For example: x=log(0.0) > results in floating point exception, but I would be very happy if -Inf was > stored into x. Another example: x=0.0/0.0 also generates floating point > exception, but I need NaN in x. Is there any solution for this problem? Me also. In prehistoric times my university had a CDC7600 mainframe that treated NaN (which it called `indefinite') and +infinity and -infinity correctly in the basic arithmetic operations (+ - * /) and in various common maths functions (sqrt(), log(), exp(), etc). If I put `MODE(1)' in the command section it would error on illegal address but keep on running for NaN and Inf. Its Fortran's PRINT had special output representations for Inf and NaN. This was often useful. I could run several sets of data knowing that it wouldn't bomb out if e.g. the first set of data caused a stray Inf. I could even set a REAL number on purpose to Inf in the program and know that 1/it would produce 0. As a useful side-effect, all uninitialized REAL variables were initialized to -Inf with its own address in its last 18 bytes, so that it was easy to find where unset REAL values had come from. It would be useful if djgpp programs could be easily settable to run in a mode which did not crash out on NaN and Inf. This week I had to run a polymerization simulation program with a variable set to various values including infinity; instead of proper infinity I had to use 1E20 and hope that that would not cause too much error in the output. On the old CDC7600 I would routinely have used Inf itself.