From: Mark Cowan Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP BUG!!!!!!! ??? Date: Thu, 06 Jan 2000 21:17:52 -0800 Organization: The University of Newcastle Lines: 83 Message-ID: <387576FF.6902831B@studentmail.newcastle.edu.au> References: <851o9m$h4t$1 AT news DOT lth DOT se> <38757518 DOT CEE78971 AT studentmail DOT newcastle DOT edu DOT au> NNTP-Posting-Host: c53h3-asy92.newcastle.edu.au Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com You probably have already thought of this but here is a work around anyway #include int main() { for ( double i = 1.0; i < 3.1; i += 0.1 ) { cout << "Double:" << (i - 1.0) << ", Integer:" << ((int) i - 1) << endl; } return (0); } Mark -- _____________________________________________ Mark Cowan Newcastle Australia Mark Cowan wrote: > I normally do casts in this way > (int) double_val > > However after doing this with your code I got the same results as you. > > Then I did a test > > double one = 1.0; > cout << "Test: " << (int) one << endl; > > gave me > Test: 1 > > weird. > > Mark > -- > _____________________________________________ > > Mark Cowan > Newcastle Australia > > Niklas Pettersson wrote: > > > Hello! > > > > I think I have found an error in DJGPP... It's illustrated by the following > > example: > > > > #include > > > > int main() > > { > > for ( double i = 0; i < 2.1; i += 0.1 ) > > { > > cout << "Double:" << i << ", Integer:" << int(i) << endl; > > } > > > > return (0); > > } > > > > You should expect it to print > > > > 0.1 0 > > .. > > .. > > 0.9 0 > > 1.0 1 > > ... > > > > but 1.0 gets converted to 0!!!! > > and even worse, 2.0 gets converted to 2... strange.. not a general > > behaviour... > > > > Is this a bug or is it me that are to dumb? (I have coded almost the whole > > night)... > > > > Any comments are appreciated > > > > / Niklas