Mail Archives: djgpp/1998/04/23/11:25:53
I ran paranoia.c today and obtained the following DEFECT printout:
Diagnosis resumes after milestone Number 90 Page: 7
Testing powers Z^i for small Integers Z and i.
* * * FLOATING-POINT ERROR 289 * * *
SR3980 failed for Z = 0.000000, Q = 0.000000!
DEFECT: computing
(0.00000000000000000e+00) ^ (1.02300000000000000e+03)
yielded 0.00000000000000000e+00;
which compared unequal to correct 1.00000000000000000e+00 ;
they differ by -1.00000000000000000e+00 .
Similar discrepancies have occurred 1 times.
To continue, press RETURN
The program is actually trying to compute pow(0,0). Where the number 1023
comes from is a mystery.
The following test program was written:
#include <float.h>
#include <math.h>
#include <stdio.h>
int main()
{
double x;
_fpreset();
x = pow(0.0,0.0);
_fpreset();
printf("pow(0,0) = %f\n", x);
return 0;
}
This produced the following:
pow(0,0) = NaN
Note that the call to pow() had to be surrounded by calls to _fpreset()
to prevent an abort printout like this:
Exiting due to signal SIGFPE
Floating Point exception at eip=0000157b
eax=00007800 ebx=000c32c0 ecx=00000000 edx=0000033e esi=00000054 edi=0000c4d0
ebp=0007ffd4 esp=0007ffcc
program=C:\DJGPP.V2\TESTS\LIBC\ANSI\MATH\PARANOIA\TSTPOW.EXE
cs: sel=00af base=807c5000 limit=000cffff
ds: sel=00b7 base=807c5000 limit=000cffff
es: sel=00b7 base=807c5000 limit=000cffff
fs: sel=0087 base=0001af10 limit=0000ffff
gs: sel=00c7 base=00000000 limit=ffffffff
ss: sel=00b7 base=807c5000 limit=000cffff
Call frame traceback EIPs:
0x0000157b
0x00001af2
Calculating 0^0 should produce 1.
K.B. Williams
- Raw text -