I have come across a few lines of coding I do not understand, and would be grateful for clarification:
if(!(counter&7))
ds->direction = ts->direction;
Thank you
I have come across a few lines of coding I do not understand, and would be grateful for clarification:
if(!(counter&7))
ds->direction = ts->direction;
Thank you
The first checks if the result of a bitwise-AND on the counter with 7 is not zero, and the latter assigns the value of the direction
member of one struct to the direction
member of another.
if counter
is a multiple of 8
set the direction
element of *ds
equal to the direction
element of *ts
1) same as
if (!(counter & 7))
if ((!(counter & 7)) != 0)
if ((counter & 7) == 0)
2) same as
(*ds).direction = (*ts).direction;
ds
(must be of a struct type) to direction of ts