Xref: utzoo comp.unix.xenix.sco:1118 comp.lang.c:34876 Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!wshb!michaelb From: michaelb@wshb.csms.com ( WSHB Operations Eng) Newsgroups: comp.unix.xenix.sco,comp.lang.c Subject: Problems compiling the ABC posting in c.u.sources Keywords: floating point exception Message-ID: <914@wshb.csms.com> Date: 21 Dec 90 19:51:40 GMT Followup-To: comp.unix.xenix.sco Organization: WSHB, Christian Science Mon. Synd., Cypress Creek, SC Lines: 125 Help, I'm trying to compile the ABC program which was just posted to c.u.sources but I can't get past a part of it. My setup is an AST 20 MHz 386 with 9 meg memory, SCO Xenix 2.3.2, Development package release 2.3. When I try to do 'make depend' there is a mkconfig.c program which gets compiled and run to set up the config.h file. This program core dumps with this: sh: 6797 Floating point exception - core dumped I have run the program and it is dying while trying to calculate the maximum possible number on my box. Here are the relevant sections of code. ===================================================== begin code fragement that blows up ===================================================== /* These routines are intended to defeat any attempt at optimisation */ Dstore(a, b) double a, *b; { *b=a; } double Dsum(a, b) double a, b; { double r; Dstore(a+b, &r); return (r); } double Ddiff(a, b) double a, b; { double r; Dstore(a-b, &r); return (r); } double Dmul(a, b) double a, b; { double r; Dstore(a*b, &r); return (r); } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is the line which blows up. Line 38. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ double Ddiv(a, b) double a, b; { double r; Dstore(a/b, &r); return (r); } double power(x, n) int x, n; { double r=1.0; for (;n>0; n--) r*=x; return r; } int floor_log(base, x) int base; double x; { /* return floor(log base(x)) */ int r=0; while (x>=base) { r++; x/=base; } return r; } int ceil_log(base, x) int base; double x; { int r=0; while (x>1.0) { r++; x/=base; } return r; } ============================================================================ end of the offending section ============================================================================ The preceeding function crashed with this from sdb Dmul(1.3482698511467e+308,2.0000000000000), line 38 ============================================================================ beginning of code fragment which calls Dmul function ============================================================================ /****** Minimum exponent ***************************************************/ if (setjmp(lab)==0) /* in case of underflow trap */ do { xminner=y; y=Ddiv(y,base); a=Dmul(y,1.0); if ((Dsum(a,a) == 0.0) || (absval(y) >= xminner)) break; } while (1); if (setjmp(lab)!=0) { printf("Unexpected over/underflow\n"); exit(1); } if (xminner != 0.0 && xminner != xmin) { printf("/\* The smallest numbers are not kept normalised *\/\n"); printf("/\* Smallest unnormalised positive number=%g *\/\n", xminner); } /****** Maximum exponent ***************************************************/ maxexp=2; xmax=1.0; newxmax=base+1.0; if (setjmp(lab) == 0) { while (xmax