anyone able to explain this???
Posted on 2003-03-13
i am using vc++ on win2k.
i was doing a simple loop, and found out that the code below behaves differently under release build and debug build.
it simply outputs integer i from 0 to 10 inclusive,
float f from 0 to 1 in steps of 0.1 inclusive,
float j from 0.25 to 2 in steps of 0.25 inclusive,
and double d from 0 to 1 in steps of 0.1 inclusive.
this works fine in debug build, BUT in release mode, float f only runs up to 0.9!!!
what is going on????? i attatch the exact code. i thought it may have something to do with doubles and floats, but float j works just fine in both modes.
i tried this:
using namespace std;
for (int i = 0; i<=10; i++)
cout<<"i = "<<i<<endl;
for (float f = 0.0; f <=1.0; f+= 0.1)
cout<<"f = "<<f<<endl;
for (float j = 0.25; j <= 2.0; j+= 0.25)
cout<<"j = "<<j<<endl;
for (double d = 0.0; d < 1.0; d+= 0.1)
cout<<"d = "<<d<<endl;