Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Floating point exceptions
@ 1998-04-14  7:32 Jacques Bouchard
  1998-04-16 20:49 ` Olaf Grundey
  0 siblings, 1 reply; 2+ messages in thread
From: Jacques Bouchard @ 1998-04-14  7:32 UTC (permalink / raw)
  To: axp-list

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



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

* Re: Floating point exceptions
  1998-04-14  7:32 Floating point exceptions Jacques Bouchard
@ 1998-04-16 20:49 ` Olaf Grundey
  0 siblings, 0 replies; 2+ messages in thread
From: Olaf Grundey @ 1998-04-16 20:49 UTC (permalink / raw)
  To: axp-list

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


Have you tried the switch -mieee ?



Olaf


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

end of thread, other threads:[~1998-04-16 19:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-04-14  7:32 Floating point exceptions Jacques Bouchard
1998-04-16 20:49 ` Olaf Grundey

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