This post is motivated by an interesting article posted above.

Also interesting uses of XOR can be found in the form of XOR swap (no-temp-swap) and XOR linked list (Doubly linked list with a single variable to store both the prev and next pointers)

Following properties of XOR are what makes it very powerful –

X^X=O (Zero) – common sense (a value xor’d with itself is bound to be zero)

X^O = X = identity

X^Y = Y^X  = Reflexivity

X^(Y^Z) = (X^Y)^Z = transitivity


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: