Possible Duplicate:
Dealing with accuracy problems in floating-point numbers
I am writing an OpenGl animation and am using a float variable "time" to keep track of the time. I am incrementing the "time" variable by 0.01 .I have certain conditions to fulfil whenever "time" reaches an integer value.The issue is that after a certain time the float increment shows weird behavior. I start from time = 0 and I see that after "time" reaches 0.83 the next value is 0.839999. I though this could be related to float precision so I tried using double/long double and I found that instead of reaching the value 1.00 the code is reaching the value 1.0000007.
I tried incrementing by "0.01f" instead of "0.01" but got no success. Is this some bug in Visual Studio or am I doing it the wrong way? I could post the code but I don't think it's of much use as I am assigning to "time" just at one place and it's just being used at other places.