Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 9 Jun 1995 02:00:43 +0200
From:      mal@algonet.se (Mats Lofkvist)
To:        bugs@FreeBSD.org
Subject:   Bogus (?) SIGFPE's from divide by zero
Message-ID:  <9506090000.AA06087@sophocles.>

next in thread | raw e-mail | index | archive | help
I don't know what the standards say, but other systems (at least SunOS)
do not issue floating point exceptions on divide by zero. Bug in FreeBSD?

Test program and outputs from FreeBSD and SunOS 4.1.4 below.

Mats Lofkvist

---testfpe.c---
#include <stdio.h>
#include <signal.h>

void handler(int foo)
{
  printf("handler\n");
}

double zero, one;

set()
{
  zero = 0.0;
  one = 1.0;
}

main()
{
  double foo;

  set();

  signal(SIGFPE, handler);

  printf("1.0/0.0\n");
  foo = 1.0/0.0;
  printf("%f\n", foo);

  printf("0.0/0.0\n");
  foo = 0.0/0.0;
  printf("%f\n", foo);

  printf("vars 1.0/0.0\n");
  foo = one/zero;
  printf("%f\n", foo);

  printf("vars 0.0/0.0\n");
  foo = zero/zero;
  printf("%f\n", foo);

  printf("done\n");
}

---

---FreBSD 2.0.5A:---
garm>a.out
1.0/0.0
Inf
0.0/0.0
NaN
vars 1.0/0.0
handler
1.000000
vars 0.0/0.0
handler
0.000000
done
---

---SunOS 4.1.4:---
mumrik>a.out
1.0/0.0
Inf
0.0/0.0
NaN
vars 1.0/0.0
Inf
vars 0.0/0.0
NaN
done
---

(The constant divisions are replaced by constants by gcc, I suppose)




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9506090000.AA06087>