From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 9950 invoked from network); 14 Apr 1998 07:31:47 -0000 Received: from onera.onera.fr (144.204.65.4) by mail2.redhat.com with SMTP; 14 Apr 1998 07:31:47 -0000 Received: from space (space [125.1.6.6]) by onera.onera.fr (8.8.5/8.8.5) with SMTP id JAA05872 for ; Tue, 14 Apr 1998 09:31:41 +0200 (MET DST) From: Jacques Bouchard Received: by space, Tue, 14 Apr 1998 09:32:29 +0200 Date: Tue, 14 Apr 1998 09:32:29 +0200 Message-Id: <199804140732.JAA26084@space> To: axp-list@redhat.com Subject: Floating point exceptions Hello I have some problems with the floating point exceptions generated by a C program on RedHat5.0/Alpha500. I have NOT these problems on Redhat5.0/Pentium120. In both cases I use gcc-2.7.2.3-8. Exceptions are raised as expected on Alpha (they are not on Intel; I don't know how to activate them but it's not really a problem), BUT THE RESULTS OF EXPRESSIONS INVOLVING "NaN" NUMBERS ARE NOT "NaN" NUMBERS. I think it is a very serious problem. Is there something to do ? Here is a small program that show the problem: > #include > #include > #include > > void handler(int type) { > printf("FLOATING POINT EXCEPTION!\n", type); > } > > void main(void) { > double x; > > signal(SIGFPE, handler); > > x = sqrt(-1.); > printf("x = %lf\n", x); > > x = acos(-2.); > printf("x = %lf\n", x); > if (x != x) printf("NAN !\n"); > > x = x * 2.; > printf("x = %lf\n", x); > if (x != x) printf("NAN !\n"); > > x = 1. / 0.; > printf("x = %lf\n", x); > if (x != x) printf("NAN !\n"); > > x = 1. / x; > printf("x = %lf\n", x); > if (x != x) printf("NAN !\n"); > } Here is what I get on Intel: > x = NaN > x = NaN > NAN ! > x = NaN > NAN ! > x = Inf > x = 0.000000 Here is what I get on Alpha: > x = NaN > x = NaN > FLOATING POINT EXCEPTION! > NAN ! > FLOATING POINT EXCEPTION! > x = 0.000000 > x = Inf > FLOATING POINT EXCEPTION! > x = 0.000000 and I don't like at all the 6th line. Can anyone help me ? Thank you Jacques