I'm getting an unexpected behaviour when comparing a float value, I understand that floats could have rounding precission issues but here numbers are quite specific to present those issues.
#include <stdio.h>
int main()
{
float alpha = 0.0f;
int finish = 0;
while (finish == 0)
{
alpha += 0.05f;
if (alpha > 1.0f)
{
printf("%f", alpha); // Expected result: 1.05f, actual result: 1.0f
finish = 1;
}
}
return 0;
}
Actually, condition enters when alpha = 1.0f. Can't understand that behaviour...
I'm compiling with MinGW (GCC 5.3.0) on Windows 10 (tested on 32bit and 64bit), Intel i5 processors.