From: wajnberg AT antibes DOT inra DOT fr (Eric Wajnberg) Newsgroups: comp.os.msdos.djgpp Subject: Strange behavior in loops!! Date: 22 Mar 2001 13:13:44 GMT Organization: I.N.R.A. Antibes (France) - Ecologie des Parasitoides Lines: 68 Message-ID: <99ctq8$t29$1@saphir.jouy.inra.fr> NNTP-Posting-Host: antibes.inra.fr X-Trace: saphir.jouy.inra.fr 985266824 29769 195.221.33.1 (22 Mar 2001 13:13:44 GMT) X-Complaints-To: usenet AT news DOT inra DOT fr NNTP-Posting-Date: 22 Mar 2001 13:13:44 GMT X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I just got the strange following behavior with DJGPP that looks like an error to me. The following simple code: #include int main(void) { float from=3,to=5,by=.5; float x; for (x=from;x<=to;x+=by) (void)printf("%g\n",x); return 0; } produces of course the values 3, 3.5, 4, 4.5 and 5. Up to now things are ok. Now look at the following other code: #include int main(void) { float from=.3,to=.5,by=.05; float x; for (x=from;x<=to;x+=by) (void)printf("%g\n",x); return 0; } Which is exactly the same than the previous one except that all values have been divided by 10. In that case, the values outputted are .3, .35, .4, and .45. In other words the value ".5" (i.e., the last one) is not outputted. Strange, isn'it? Of course the real problem I am facing now is much more complicated than this one (the length of my code is currently of several thousand lines), but these small examples explain it clearly. I've made several other tests, but I'm keeping on obtaining the same problem. Did I missed something? Thanks for any help on that. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Eric Wajnberg Directeur adjoint du GDR CNRS 2155 Ecologie Comportementale I.N.R.A. 37, Bld. du Cap. 06600 Antibes. France. Tel : (33-0) 4.93.67.88.92 Fax : (33-0) 4.93.67.88.97 e-mail : wajnberg AT antibes DOT inra DOT fr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~