i was playing around with c++ recently and for laughs and giggles i came up with this little program
Code:
#include <iostream>
using namespace std;
int main ()
{
for (long double n=100; n>0; n = n/2) {
cout << n << "\n ";
}
cout << "FIRE!\n";
return 0;
}
theoretically that should be an infinite loop but it in fact does terminate eventually echoing out 'FIRE!'
just wondering if even though in theory this should be an infinite loop (a number repetedly divided by 2 should never reach 0 thus the conditions of the loop should never be satisfied, hence infinite loop) perhaps in practice limitations of the variable types prevent this?
no this is not homework just a question to help understand the mechanics of variables and loops