Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
flohofwoe
on Jan 18, 2021
|
parent
|
context
|
favorite
| on:
That XOR Trick (2020)
It also works if both are equal since only one value will ever be zero:
x=2, y=2:
x^=y => x=0, y=2
y^=x => x=0, y=2
x^=y => x=2, y=2
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search:
x=2, y=2:
x^=y => x=0, y=2
y^=x => x=0, y=2
x^=y => x=2, y=2