Mercurial > hg > octave-nkf
diff src/sysdep.cc @ 444:ba637cc5c5f3
[project @ 1994-06-02 17:15:07 by jwe]
author | jwe |
---|---|
date | Thu, 02 Jun 1994 17:15:07 +0000 |
parents | 0823483a6277 |
children | 693d18604ccb |
line wrap: on
line diff
--- a/src/sysdep.cc +++ b/src/sysdep.cc @@ -28,6 +28,13 @@ #include <stdlib.h> #include "error.h" +#include "sysdep.h" + +// Octave's idea of infinity. +double octave_Inf; + +// Octave's idea of not a number. +double octave_NaN; #if defined (__386BSD__) && defined (HAVE_FLOATINGPOINT_H) #include <floatingpoint.h> @@ -58,6 +65,53 @@ } #endif +static void +octave_ieee_init (void) +{ +#if defined (HAVE_ISINF) || defined (HAVE_FINITE) + +// Some version of gcc on some old version of Linux used to crash when +// trying to make Inf and NaN. + +#if defined (HAVE_INFINITY) + octave_Inf = infinity (); +#else +#ifdef linux + octave_Inf = HUGE_VAL; +#else + double tmp = 1e+10; + octave_Inf = tmp; + for (;;) + { + octave_Inf *= 1e+10; + if (octave_Inf == tmp) + break; + tmp = octave_Inf; + } +#endif +#endif + +#if defined (HAVE_QUIET_NAN) + octave_NaN = quiet_nan (); +#else +#ifdef linux + octave_NaN = NAN; +#else + octave_NaN = octave_Inf / octave_Inf; +#endif +#endif + +#else + +// This is sort of cheesy, but what can we do, other than blowing it +// off completely, or writing an entire IEEE emulation package? + + octave_Inf = DBL_MAX; + octave_NaN = DBL_MAX; + +#endif +} + void sysdep_init (void) { @@ -69,6 +123,8 @@ #ifdef NeXT NeXT_init (); #endif + + octave_ieee_init (); } /*