Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
When you want to output to be false when same and true when different. What do you mean how does one use XOR?
-
Only when I want to confuse the fuck out the next dev.
I output errors messges using a random key xor'ed string. unique per error msg. Let them have fun searching trough the code... -
You can use it to toggle specific bits:
x ^= 0x01;
This will leave all bits of x as they are, except the least significant one, which will change its state. -
I would stay away from bitwise operators unless your doing operations on bitfields.
You can do clever things, but they aren't very clear for maintenance. Maybe if you put it into a well named function call or macro and it's there for speed purposes only.
For the first time in 20 years I used and xor operator.
I wrote in line of code instead of two.
How uses the xor operator?
rant
logic
boolean