Date: Thu, 8 Apr 93 10:06:33 +0200 From: kuku AT acds DOT physik DOT rwth-aachen DOT de (Christoph Kukulies) To: ae1181t AT stnfor DOT ae DOT ge DOT com, djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: bug in double >Graeme Gill writes: >> I have discovered a bug in the handling of >> floating point constants that caused a significant error >> in a program I am trying to compile. >> >> The workaround is to change line in include/values.h below >> #if defined(i396) >> >> from >> >> #define MAXDOUBLE 1.79769313486231570e+308 >> >> to >> >> #define MAXDOUBLE 1.79769313486231470e+308 >> ^ this digit changes. > >I'm at work so I can't test your program on a PC. For what it's >worth, I ran your test program on my workstation, and it works fine. > >I'm responding to this because I believe that the existing value for >MAXDOUBLE is "correct" in that it reflects the correct maximum value >for 64-bit floating point numbers in IEEE format. Rather than change >MAXDOUBLE, we really should figure out why this correct value is not >working properly, and fix that. (Do you have a 486, a 386+387, or >386+emulator? Maybe this is just an emulator bug.) >It would be interesting to look at the actual bit pattern that the >compiler is generating for these floating point numbers. Here's a >program that would print it: > >#define MAXDOUBLE 1.79769313486231570e+308 >#define ALMOSTMAX 1.79769313486231470e+308 > >double dd = MAXDOUBLE; >double ddd = ALMOSTMAX; > >int >main() >{ > (void) printf("MAXDOUBLE = %.20e\n", MAXDOUBLE); > (void) printf("ALMOSTMAX = %.20e\n", ALMOSTMAX); > (void) printf("dd = %.20e = 0x%8.8x 0x%8.8x\n", > dd, *(int *) &dd, *((int *) &dd + 1)); > (void) printf("ddd = %.20e = 0x%8.8x 0x%8.8x\n", > ddd, *(int *) &ddd, *((int *) &ddd + 1)); >} >On my (big endian) workstation, this prints: > >MAXDOUBLE = 1.79769313486231570000e+308 >ALMOSTMAX = 1.79769313486231470000e+308 >dd = 1.79769313486231570000e+308 = 0x7fefffff 0xffffffff >ddd = 1.79769313486231470000e+308 = 0x7fefffff 0xfffffffa >-- > Eric Backus > ericb AT lsid DOT hp DOT com > (206) 335-2495 On my 386BSD system I'm getting: Script started on Thu Apr 8 09:56:24 1993 386bsd> gcc eric.c 386bsd> a.out MAXDOUBLE = 1.79769313486231570000e+308 ALMOSTMAX = 1.79769313486231570000e+308 dd = NaN = 0x00000002 0x7ff00000 ddd = 1.79769313486231570000e+308 = 0xffffffff 0x7fefffff 386bsd> Script done on Thu Apr 8 09:57:35 1993 --Chris Christoph P. U. Kukulies kuku AT acds DOT physik DOT rwth-aachen DOT de *** Error code 1 Stop.