It's 91 because I want the option to be from -90 to 90, and nothing above or below. |
What if I input +/-90.5?
I also added sleep(1) to the end of the loop, to free up clock cycles. |
Um... Why?
The program is not doing nothing. It's calculating results. Using anything less than all available computing power is a waste.
Yielding is only acceptable if the thread is waiting for something to complete, like a lengthy I/O operation (network and users being the biggest bottlenecks), or perhaps a different thread doing an operation on shared data, but not when the thread is doing something useful.
Actually, I've heard of people sprinkling Sleep()s in code to not make it too fast. Apparently some people (lusers, mostly) think that if the computer responds immediately, it's not doing anything important.
As an unexpected result, the refresh rate of the counter is now 1Hz |
It's not unexpected, it only looks that way to you:
The granularity of Sleep() is 10 ms (actually, that's the granularity of the kernel's scheduler which is responsible of allocating CPU time to the different threads), so even if you Sleep(1), on average you'll Sleep(10).
Now, what I do find surprising is that the program is simulating at 1x, even though the time step is 1 ms. If the minimum Sleep() is 10 ms, then it should simulate at .1x. Are you by chance running a 9x/ME kernel? I've read that those schedulers have a finer granularity.
In any case, You should remove that Sleep(). And while you're at it, get rid of conio.h (ugh).