hey guys,
what should i write to make i between 0 and 60 (if i<60 should i return to 0 and if i>0 i should return to 60 )
int i = 0..60 ;
thank you
hey guys,
what should i write to make i between 0 and 60 (if i<60 should i return to 0 and if i>0 i should return to 60 )
int i = 0..60 ;
thank you
Context, please.
Paul
Your conditions do not make sense. If i is a value like 23, it is both < 60 and > 0 so what should happen?
if (Char=='a') {
i=i+1;
}
if (Char=='b')) {
i=i-1;
}
I can change i with an tft touch and I should be not more than 60 and not less than 0 that why i ask.
i mean the maximun should be 60 and if i>=60 , i should return to 0.
Never used it, but "constrain"?
if (Char=='a') {
i=i+1;
}
if (Char=='b') {
i=i-1;
}
if ( i < 0 ) i = 60;
if ( i >= 60) i = 0;
i %= 60;
...oops problem with negative numbers though...
so
i = (i + 60) % 60;
thank you
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.