Created
December 25, 2013 07:23
-
-
Save wcarss/8120951 to your computer and use it in GitHub Desktop.
A test of bitwise and used to increment and wrap access into an array in doom's event-handling.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() { | |
int SIZE = 10; | |
int head = 0; | |
int tail = 0; | |
head = 3; | |
tail = 5; | |
printf("size-1: %d, head: %d, tail: %d, tail&SIZE-1: %d\n", SIZE-1, head, tail, tail&(SIZE-1)); | |
for(; tail != head; tail = (++tail)&(SIZE-1)) { | |
printf("size-1: %d, head: %d, tail: %d, tail&SIZE-1: %d\n", SIZE-1, head, tail, tail&(SIZE-1)); | |
} | |
printf("size-1: %d, head: %d, tail: %d, tail&SIZE-1: %d\n", SIZE-1, head, tail, tail&(SIZE-1)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment