delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/06/04:55:22

From: "Niklas Pettersson" <npedt97 AT student DOT vxu DOT se>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP BUG!!!!!!! ???
Date: Thu, 6 Jan 2000 10:45:03 +0100
Organization: Lund Institute of Technology, Sweden
Lines: 39
Message-ID: <851o9m$h4t$1@news.lth.se>
NNTP-Posting-Host: npedt97.univ.vxu.se
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello!

I think I have found an error in DJGPP... It's illustrated by the following
example:

#include <iostream>

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



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019