c - floating point while loop -


int main() {     float x = 50;     float y = 1/x;     float result = y * x;      float test = 41;     float z = 1/test;     float testres = z * test;       while (result == 1)     {             x--;     }      printf("%f\n", x);     printf("%.6f\n", testres); } 

my while loop infinite, never ends, should end @ 41 because when test 41, equals 0.99999404

result never changes within loop, therefore there no reason believe that, once starts, loop ever end.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -