Xref: news2.mv.net comp.os.msdos.djgpp:7149 From: jhvogel AT me DOT umn DOT edu (Jeff Vogel) Newsgroups: comp.os.msdos.djgpp Subject: math addition error? Date: 12 Aug 1996 15:26:34 -0500 Organization: me.umn.edu -- UMN Mechanical Engineering Lines: 44 Message-ID: NNTP-Posting-Host: ena.me.umn.edu Keywords: math bug To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp I have recently encountered some strange behavior from a djgpp compiled program, and I would appreciate any advice on what to do. I traced an error in a program to what appeared to be an addition error, and I was able to reproduce the error in a simple program that only adds the numbers and prints the result: #include main() { double x=3.6053320875, y=3.6053320870; printf( "%lf\n", x-y ); } I compile the code as follows: gcc -ojunk junk.c and run it with the following results: go32 junk -3.9999999995000 I get a similar answer (not identical, though) for a small range of number pairs around the ones I've shown here, but if the numbers are different from these by more than about 1e-10, I get the right answer. My machine is a 486SX (no co-processor) 25MHz (I think - one piece of info I have suggests it might actually be a 33 MHz clock). I compiled and ran the code in native MSDOS using gcc v 2.67. When I tried to reproduce this error on a pentium 90, I did not get an error. Because I can't reproduce this error on another machine, I'm not optimistic about solving it, but any suggestions would be much appreciated. Jeff Vogel jhvogel AT me DOT umn DOT edu -- Jeff Vogel jhvogel AT me DOT umn DOT edu