-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello,
even if I`m not THE Pro coding c++
I thought I`m already better not to ask the following: 

#include<iostream>
using namespace std;

int main(){

        double i = 4;
        while( i != 0 ){

                cout << endl << "I = " << i << endl;

        if( i < 0 ){ i += 0.1; }
        if( i > 0 ){ i -= 0.1; }
        }

return 0;
} 

Why does this result in:

...

I = 0.3

I = 0.2

I = 0.1

I = -2.41474e-15

I = -2.41474e-15

I = -2.41474e-15

I guess my plan in here is obvious.
It does not matter whether i is positive or negative while will
stop when i is 0.

But is doesn`t.

I use g++ (GCC) 3.3.5 (Debian 1:3.3.5-13) from sarge.

Regards
Wilhelm Korrengk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFEJ1Rq4ePYIBYoTy4RAga4AJ9Bfeyyhf3/0lifkUDgfanyovMKiwCfdPEy
//bINt6f6dnMH9n0d1WmeEk=
=7MK1
-----END PGP SIGNATURE-----
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to