Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Jacques Bouchard <bouchard@onera.fr>
To: axp-list@redhat.com
Subject: Floating point exceptions
Date: Tue, 14 Apr 1998 09:32:29 +0200	[thread overview]
Message-ID: <199804140732.JAA26084@space> (raw)

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 <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



             reply	other threads:[~1998-04-14  7:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-14  7:32 Jacques Bouchard [this message]
1998-04-16 20:49 ` Floating point exceptions Olaf Grundey
read-only archive

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