michaelb@wshb.csms.com ( WSHB Operations Eng) (12/22/90)
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<newxmax) { xmax=newxmax; newxmax=Dmul(newxmax, base); !!!!!!!!!! ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ !!!!!!!!!! ((This is the line sdb says calls the final straw)) !!!!!!!!!! !!!!!!!!!! if (Ddiv(newxmax, base) != xmax) break; /* ieee infinity */ maxexp++; } } if (setjmp(lab)!=0) { printf("Unexpected over/underflow\n"); exit(1); } printf("/\* Maximum exponent=%d *\/\n", maxexp); /****** Largest and smallest numbers ************************************/ xmax=Ddiff(1.0, epsneg); if (Dmul(xmax,1.0) != xmax) xmax=Ddiff(1.0, Dmul(base,epsneg)); for (i=1; i<=maxexp; i++) xmax=Dmul(xmax, base); printf("/\* Maximum number=%g *\/\n", xmax); ============================================================================ end of code fragment ============================================================================ Everything seems to run fine through the Minimum exponent section as I get the 'Smallest unnormalised positive number' report. It core dumps immediatly after that. I don't understand is what is different about the Dmul function in the Maximun exponent call. It seems to work correctly several times before the program gets to that point. Does anyone have any pointers? If so, please send me an answer which will be meaningful to a knowledgable amateur. I don't do 'c' for a living. I just get things working. Michael -- Michael Batchelor--Systems/Operations Engineer #compliments and complaints WSHB - An International Broadcast Station of # letterbox@csms.com The Christian Science Monitor Syndicate, Inc. #technical questions and reports michaelb@wshb.csms.com +1 803 625 4880 # letterbox-tech@csms.com