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