pi problem with 5.0b
15-Jul-90 16:21:22
Sb: pi problem with 5.0b
Fm: John G. Ata 72017,145
To: Mike Spille/Manx 71545,1466
Mike,
I have discovered the problem with the pi problem. It is not a code
generation problem. Rather, the program assumes that the following
construct will initialize both a and b to 0:
int a, b = 0;
The compiler, however, only sets b to zero while a has a garbage value.
This garbage value was upsetting the result. It turns out, after debugging
with sdb, that the 16 bit version did the same thing only the garbage value
was much smaller and so the final answer was much closer. Changing the
lines in math.c to the form:
int a = 0, b = 0;
solved the problem. Is the first form supposed to work? The first edition
if K & R suggests not, but then why is Microsoft using it? Is it perhaps a
Unix standard and not ANSI? Just curious…
John