Check within a 16 bytes window
Here is the problem.
I have a counter that is 16 bits wide. Also another 16 bits counter.
I need to check if the distance between them is no more that 16 bytes.
The tricky part is where the one is near the roll over and the other has already rolled.
For example one counter is at FFFC and the other is at 0003.
Any ideas?
Ioannis
Re: Check within a 16 bytes window
Code:
IF ABS(count1 - count2) > 16 THEN ...
Re: Check within a 16 bytes window
Every time I get an answer by Darrel, I feel I have to hide somewhere... Embarassed.
Thanks Darrel.
Ioannis
Re: Check within a 16 bytes window
Well, don't feel too bad, cause I'm not even sure that will work under all conditions.
I should do some testing.
Re: Check within a 16 bytes window
After some testing ... it does work.
Now I want to hide. :o
Re: Check within a 16 bytes window
I just did not think in terms of pure binary maths. So trying to find a way with 10 base mind was driving me away from the clear solution you gave.
Thanks again.
Ioannis