I need help to figure out what went wrong... As I am just learning how to program this, I was testing out a 'for' statment:
~~~Code://SomeCrazyGuy //'For' Looping Test #include <iostream.h> #include <stdlib.h> using namespace std; int main () { float a; for(a=0;a<=1;a=a+.01) { cout<< a <<endl; } system("pause"); return 0; }
While the result was find for a short moment, something quite odd happened:
0
.1
.2
.3
...
.81
.82
.83
.839999
.849999
...
.999999
Press any key to continue . . .
Mainly from curiosity, but also from a need, I wish to know how this went wrong, when it went wrong, and how it can be fixed so I may avoid this in future programs.
Thank you for any and all help you provide, it is greatly appreciated! n_n