Archive for the ‘bit-twiddling’ Category

Many people have heard of how to swap two values without using temporary storage, using XORs. This is often summarised as: a ^= b ^= a ^= b; There are other operators that can be used to do the swap, but in the degenerate case, this essentially becomes the XOR trick again.



Follow

Get every new post delivered to your Inbox.