Date: Mon, 11 Aug 2003 09:28:05 -0400 Message-Id: <200308111328.h7BDS5un031026@envy.delorie.com> From: DJ Delorie To: djgpp-workers AT delorie DOT com In-reply-to: (message from Eli Zaretskii on 11 Aug 2003 07:53:19 +0200) Subject: Re: Anomaly in printf() References: <1e0 DOT eca6e87 DOT 2c67e363 AT aol DOT com> <200308101817 DOT h7AIHDhr019129 AT envy DOT delorie DOT com> <9003-Sun10Aug2003222306+0300-eliz AT elta DOT co DOT il> <200308102312 DOT h7ANC6mQ021365 AT envy DOT delorie DOT com> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > In a long double, the mantissa includes the integer bit, unlike in a > float or a double. Se we lose one bit. The 80387 book claims that there's 64 bits of mantissa (0..63), one bit of sign (79), and 15 bits of exponent (64..78). > (I'd be interested in seeing the actual bit patterns of the numbers > as shown by a debugger; I'm quite sure these bit patterns are okay.) Linux prints this: 00 00 40 3e ff ff ff ff ff ff ff ff = 18446744073709551615.000 00 00 40 3e ff ff ff ff ff ff ff fe = 18446744073709551614.000 00 00 40 3e ff ff ff ff ff ff ff fd = 18446744073709551613.000 00 00 40 3e ff ff ff ff ff ff ff fc = 18446744073709551612.000 > Since _doprnt does some amount of math on its argument, loss of > precision beyond the significant digits is inevitable. If that's our excuse, it's still a bug. We should choose better methods so that we don't lose precision.