On Fri, 1 Aug 1997, Justin wrote: > Sorry, for the C-ignorant question, but what the heck does this do:? > > from class.c: > temp ^= table[k]; > table[k] ^= temp; > temp ^= table[k]; > > Appears to me to traveling in circles... Not really. Try a simple test program to see what it's doing: /* xor.c - demonstrate the obscure bitwise XOR operator */ #include <stdio.h> #include <stdlib.h> int main(void) { int a = 5, b = 3; printf("a = %d b = %d\n\n", a, b); a ^= b; printf("a ^= b a = %d b = %d\n", a, b); b ^= a; printf("b ^= a a = %d b = %d\n", a, b); a ^= b; printf("a ^= b a = %d b = %d\n", a, b); return; } I don't know if this is actually faster than swapping ints the old fashioned way or if Jeremy (or the diku gang?) did this for fun. Sam +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST