Using float / double as a loop variable
问题 Running on a x64 architecture , Visual Studio 2013 Windows 8.1 I am trying to run a loop which uses a float as its loop variable , the issue is during the increment operation the decimal values are being lost . Eg : float incrementValue = 360 / 14; for (float i = 0; i <= 360; i = i + incrementValue) { cout << endl << " I " << i; } I need the value of i >= 360 . But it stops at 350 . Since 360/14 =25.7142857 but looks like the increments are in steps of 25 . If i do the same thing with any