Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* NaN in C/C++ on OSF1
@ 1995-12-01  5:00 Jan Christian Kerlefsen
  1995-12-07  5:00 ` Steven Hobbs
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Christian Kerlefsen @ 1995-12-01  5:00 UTC (permalink / raw)



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 <math.h>
#include <iostream.h>
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



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1995-12-08  5:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1995-12-01  5:00 NaN in C/C++ on OSF1 Jan Christian Kerlefsen
1995-12-07  5:00 ` Steven Hobbs
1995-12-08  5:00   ` Tanmoy Bhattacharya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox