3 ms·
I'd been using xor swapping for years as x ^= y ^= x ^= y; until some point it occurred to me that this has undefined behavior in C.
by utopcell 6y ago
I'd been using xor swapping for years as
x ^= y ^= x ^= y;
until some point it occurred to me that this has undefined behavior in C.
- Aardwolf 6y agoThat's one thing missing from BASIC in other programming languages, the SWAP statement: SWAP x y So few other languages have it, some languages even make it impossible to write a swap function by not supporting pass by reference or pointers. Python has something interesting except it requires typing the name of each variable twice