Why is stdio.h included?
It was just from the bigger program I tried to split to smallest one where the error still exists and I forgot include there. If I remove all includes, it still works same way wrong.
Software isn't my strong suit, but shouldn't it be:
if ( (!dOn && n1000) >= 500 ) {
Does not matter, because && has stronger precedence than >=.
In case of clarity this would of course be better.
Still none of the above is the problem. The problem is that something weird is with division.