On 21/02/10 01:10, Κράκ Άουτ wrote: > So, looking at your code, can I limit updates to 1/sec instead of > 60/sec? Changing this line, > `if ((ev.xmotion.time - lasttime) <= (1000 / 60))` > to > `if ((ev.xmotion.time - lasttime) <= (1000 / 1))` > would be enough? > > Can I also achieve 0/sec somehow? I suggested 1/sec because division by > zero is not possible.
I'm not familiar with the context of the quoted code, but it looks like if checks for the time difference between the current time and last recorded time. The check succeeds if the difference is 1000/60 ~ 17 in the first case and 1000 in the second case. As the divisor gets closer to zero, the threshold against which the difference is tested becomes greater. As you said, division by zero is not possible. The division is there in the first place purely for the sake of code clarity, the difference is an integer constant and can be specified as just a single number, without the division. From the purely logical standpoint, "achieving 0/sec" would be equivalent to not executing the code in the if-block at all, and would be best accomplished by commenting the block out.
signature.asc
Description: PGP signature