[cs615asa] Question about wrap

Jan Schaumann jschauma at cs.stevens.edu
Sat Apr 18 13:19:07 EDT 2009


Chih-Yuan Lee <clee9 at stevens.edu> wrote:
 
> They said if the value(t)-value(t-1) is negative the counter has 
> wrapped. So the formula will be different. 

Correct.

> Would you please tell us some information about 32 bit counter and 64 
> bit counter?? 

You can look this up or figure it out on your own, I'm sure.  Terse
summary: the information is stored in a data type of a certain size,
which, if larger values than can be stored are used, wraps around,
yielding negative values.

> And do we need to consider this kind of situation? Can we just  replace 
> negative value by positive value like using " absolute value "??

No, that would not be accurate.  Suppose your counter wraps at 10 and
you start counting at value 8, then your sequence is 8 9 0 1 2 3, and
your difference would be 8 + -3 = 5.  If you used absolute values, you'd
reach a different result (8 + 3 = 11).

Hence your code needs to account for the possibility of the counter
wrapping.

-Jan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 186 bytes
Desc: not available
Url : https://lists.stevens.edu/cgi-bin/mailman/private/cs615asa/attachments/20090418/8a8b4b19/attachment.pgp 


More information about the Cs615asa mailing list