View Single Post
Old 11-08-2005, 03:55 PM   #7 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
^= is Bitwise exclusive OR and assign, which means it will XOR the bit's between the two and assign the value at the same time ie:
Code:
bit_a = 10011010
bit_b = 01011010

bit_a ^= bit_b (bit_a = (10011010 ^ 01011010) => bit_a = 11000000 )
bit_b ^= bit_a (bit_b = (01011010 ^ 11000000) => bit_b = 10011010 )
bit_a ^= bit_b (bit_a = (11000000 ^ 10011010) => bit_a = 01011010 )
As you can see, by that logic it will swap the two of them, so if you're dealing with complete bitwise opreations, this is the way..
But on the other hand, will a STORE versus a XOR instruction be faster for the CPU ?
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote