Mail Archives: djgpp-workers/2001/12/15/06:11:29
Hello.
Eli Zaretskii wrote:
[snip]
> > Using the math co-pro (387 not set or set to y) gives a result of
> > 0.122385; using a patched emu387.dxe gives a result of 0.1. Shouldn't
> > the results be the same or at least a little closer?
>
> They should be very close. Does the same happen with other argument
> values to atan? What about sin and cos?
Please find the new test program at the end of this mail. Below is what it
produces. My 2.03 install is in c:/djgpp. My CVS checkout is in
c:/develop/djgpp.rw. The libraries built against CVS have profiling turned
on. I compiled the test program with gcc 3.0.2 with the following lines
for against 2.03 and CVS respectively:
gcc -Wall -g -o m m.c
gcc -Wall -g -I/develop/djgpp.rw/include -L/develop/djgpp.rw/lib \
-o m m.c
Built against 2.03, default environment (i.e. detects math co-pro in my
Athlon chip):
80387 detected.
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161
Built against CVS, default environment (i.e. detects math co-pro in my
Athlon chip):
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161
Built against 2.03, 387=n, EMU387=c:/djgpp/bin/emu387.dxe:
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161
Built against CVS, 387=n, EMU387=c:/develop/djgpp.rw/bin/emu387.dxe:
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.09, sin(0.1) = 0.09, cos(0.1) = 4e-06
atan(0.2) = 0.1, sin(0.2) = 0.1, cos(0.2) = 6e-05
atan(0.2) = 0.2, sin(0.2) = 0.2, cos(0.2) = 0.0003
atan(0.3) = 0.3, sin(0.3) = 0.3, cos(0.3) = 0.001
atan(0.4) = 0.4, sin(0.4) = 0.4, cos(0.4) = 0.002
atan(0.5) = 0.5, sin(0.5) = 0.5, cos(0.5) = 0.005
atan(0.6) = 0.6, sin(0.6) = 0.6, cos(0.6) = 0.009
atan(0.7) = 0.6, sin(0.7) = 0.7, cos(0.7) = 0.01
atan(0.8) = 0.7, sin(0.8) = 0.7, cos(0.8) = 0.02
Built against 2.03, 387=n, EMU387=c:/develop/djgpp.rw/bin/emu387.dxe:
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.09, sin(0.1) = 0.09, cos(0.1) = 4e-06
atan(0.2) = 0.1, sin(0.2) = 0.1, cos(0.2) = 6e-05
atan(0.2) = 0.2, sin(0.2) = 0.2, cos(0.2) = 0.0003
atan(0.3) = 0.3, sin(0.3) = 0.3, cos(0.3) = 0.001
atan(0.4) = 0.4, sin(0.4) = 0.4, cos(0.4) = 0.002
atan(0.5) = 0.5, sin(0.5) = 0.5, cos(0.5) = 0.005
atan(0.6) = 0.6, sin(0.6) = 0.6, cos(0.6) = 0.009
atan(0.7) = 0.6, sin(0.7) = 0.7, cos(0.7) = 0.01
atan(0.8) = 0.7, sin(0.8) = 0.7, cos(0.8) = 0.02
Built against CVS, 387=n, EMU387=c:/djgpp/bin/emu387.dxe:
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161
So I conclude that there's something very wrong with emu387.dxe built
against CVS.
I rebuilt without profiling, but the result was the same. I downgraded to
gcc 2.95.3 and it worked again:
atan(0) = 0, sin(0) = 0, cos(0) = 1
atan(0.1) = 0.0996687, sin(0.1) = 0.0998334, cos(0.1) = 0.995004
atan(0.2) = 0.197396, sin(0.2) = 0.198669, cos(0.2) = 0.980067
atan(0.3) = 0.291457, sin(0.3) = 0.29552, cos(0.3) = 0.955336
atan(0.4) = 0.380506, sin(0.4) = 0.389418, cos(0.4) = 0.921061
atan(0.5) = 0.463648, sin(0.5) = 0.479426, cos(0.5) = 0.877583
atan(0.6) = 0.54042, sin(0.6) = 0.564642, cos(0.6) = 0.825336
atan(0.7) = 0.610726, sin(0.7) = 0.644218, cos(0.7) = 0.764842
atan(0.8) = 0.674741, sin(0.8) = 0.717356, cos(0.8) = 0.696707
atan(0.9) = 0.732815, sin(0.9) = 0.783327, cos(0.9) = 0.62161
So it looks like a code generation issue.
> Also, could you please try the same on plain DOS? I don't trust the
> Windows DPMI server as far as FP emulation is considered.
If the above isn't enough to prove that gcc 3.0.x is the problem, then
I'll be happy to rerun on DOS. I only have Windows '98 SE, but presumably
its DOS mode would be OK.
BTW is emu387 documented anywhere? If not, I'll whip up a quick manual for
it, describing what it does, what effect the 387 & EMU387 environment
variables, etc.
Thanks, bye, Rich =]
--
Richard Dawe
http://www.phekda.freeserve.co.uk/richdawe/
---Start m.c---
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int
main (void)
{
double l, d;
for (l = 0; l < 0.9; l += 0.1)
{
d = atan(l);
printf("atan(%g) = %g, ", l, d);
d = sin(l);
printf("sin(%g) = %g, ", l, d);
d = cos(l);
printf("cos(%g) = %g\n", l, d);
}
return(EXIT_SUCCESS);
}
---End m.c---
- Raw text -