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

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

node.js - Express and Redis - If session exists for this user, don't allow access -