Message-Id: <3.0.6.32.19990929225059.0079a180@dce03.ipt.br> X-Sender: csrabak AT dce03 DOT ipt DOT br X-Mailer: QUALCOMM Windows Eudora Light Version 3.0.6 (32) Date: Wed, 29 Sep 1999 22:50:59 -0300 To: djgpp AT delorie DOT com From: "Cesar S. Rabak" Subject: Re: djgpp and rounding errors In-Reply-To: References: <37F173EB DOT 77A2 AT linetap DOT com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk At 10:37 29/09/99 +0200, Eli Zaretskii wrote: > >On Tue, 28 Sep 1999, nebo wrote: > >> Does DJGPP fix rounding errors with decimal places? I know >> some compilers use BCD math to circumvent this problem, but >> I found nothing of the sort in DJGPP. > >Please explain more about what you are asking. What rounding errors >did you have in mind, and why do they need fixing with BCD? > >Floating-point computations in DJGPP run with 80-bit internal >precision of the numerical co-processor, if that helps. > > Try this small snippet in your machine: #include #include int main(void) { int i; float number = 0.0f; for (i=0; i< 10000000; i++) number += 0.001; printf("Result is %5.2f\n", number); return 0; } In _my_ equipment (a 233MMX Pentium running Win95), gcc 2.8.1: bash$ gcc -o teste teste.c bash$ ./teste Result is 9780.20 This is a problem common to all programming languages, and has to do with the representation of numbers in binary form. Nor 80 bit helps here. . . Hope this clarifies. This problem for certain application domains (e.g. when calculations about money are being done) is more than a nuisance, this is the reason why the BCD stuff was developed. HTH Cesar