From: Mark Cowan Newsgroups: comp.os.msdos.djgpp Subject: Re: DJGPP BUG!!!!!!! ??? Date: Thu, 06 Jan 2000 21:09:44 -0800 Organization: The University of Newcastle Lines: 61 Message-ID: <38757518.CEE78971@studentmail.newcastle.edu.au> References: <851o9m$h4t$1 AT news DOT lth DOT se> 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 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