From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,a0149c61779a35a7,start X-Google-Attributes: gid109fba,public X-Google-Thread: 1014db,a0149c61779a35a7,start X-Google-Attributes: gid1014db,public X-Google-Thread: fee84,a0149c61779a35a7,start X-Google-Attributes: gidfee84,public From: janchr@holt.nr.no (Jan Christian Kerlefsen) Subject: NaN in C/C++ on OSF1 Date: 1995/12/01 Message-ID: <49mnlh$5a3@ratatosk.uio.no>#1/1 X-Deja-AN: 120592763 organization: Norsk Regnesentral (NR) keywords: NaN, OSF1 newsgroups: comp.unix.osf.osf1,comp.lang.c,comp.lang.c++ Hi! I'm porting an application developed on SunOS 4.1.3, to a Dec Alpha with OSF1 v3.2. The application is implemented in C++ and compiled with gcc 2.6.3. It is essencial for the application that double and float variables can be NaN (not a number). On Sun i use the function 'double quiet_nan()' in 'libm', and on AIX 3.2 I use sqrt(-1.0) to get the NaN value. The 'libm' on OSF1 has the function 'int isnanf(float)' that gives the correct response when I use FLT_QNAN defined in float.h. i.e. float a = FLT_QNAN; if (isnanf(a)) cerr << a; works fine, and prints 'NaN' to std.out. But: float a = FLT_QNAN; float b = 1.0; float c; c=a+b; crashes with a floating exception. I had expected c to be assigned NaN. sqrt(-1.0) returns 0 (!), and isnan(sqrt(-1.0)) returns 0 on the OSF1. On sun: #include #include main() { float a = quiet_nan(); float c,b=1.0; c=a+b; cerr << c; } works as expected and prints 'NaN' to std.out. I need a 'quiet nan' on OSF1 that works the same way as it does on Sun. By the way, when linking on the OSF1, I get the following warning: /usr/bin/ld: Warning: Linking some objects which contain exception information sections and some which do not. This may cause fatal runtime exception handling problems (last obj encountered without exceptions was (some file..) I've been told that this warning can be ignored. Is this true, also in the case with the 'NaN' problems? Thanks in advance for help! Jan Christian Kerlefsen email: Christian.Kerlefsen@nr.no Research Scientist Phone: +47 22 85 25 00 Norwegian Computing Centre Fax: +47 22 69 76 60