Bug or is it me?

Rogelio Nodal rnodal at pegasus.rutgers.edu
Sun Oct 30 02:28:14 UTC 2005


Hello List:

    Is this a bug?Or is it me?

    [code]

    /* Created by Anjuta version 1.2.4 */
    /*    This file will not be overwritten */

   #include <iostream>
   #include <fstream>

   using namespace std;

   int main()
   {
   
   
   
    double x = 0;
   
   
    x = -2.3;
    while(x <= 2.1)
    {
        cout << x << endl;
        x += 0.1;
    }
   
    return (0);
   }
 
    [code]


    When I run this little program I get the following output:


    -2.3
-2.2
-2.1
-2
-1.9
-1.8
-1.7
-1.6
-1.5
-1.4
-1.3
-1.2
-1.1
-1
-0.9
-0.8
-0.7
-0.6
-0.5
-0.4
-0.3
-0.2
-0.1
1.082e-15    ===> What the hell?
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1
1.1
1.2
1.3
1.4
1.5
1.6
1.7
1.8
1.9
2       === Why did it stop here?It is supposed to stop at 2.1.



Thanks a lot for your time.


    Rogelio.





More information about the ubuntu-users mailing list