bitwise operations

// Multiply by a power of 2
x = x << 1; // x = x * 2
x = x << 6; // x = x * 64

// Divide by a power of 2
x = x >> 1; // x = x / 2
x = x >> 3; // x = x / 8

// Swap integers without a temporary variable
a ^= b; // int temp = b
b ^= a; // b = a
a ^= b; // a = temp

// Increment / Decrement (slower but good for obfuscating)
i = -~i; // i++
i = ~-i; // i--

// Sign flipping
i = ~i + 1; // or
i = (i ^ -1) + 1; // i = -i

// Modulo operation if divisor is power of 2
x = 131 & (4 - 1); // x = 131 % 4

// Check if an integer is even or odd
(i & 1) == 0; // (i % 2) == 0

// Equality check
(a^b) == 0; // a == b

// Absolute value
x < 0 ? -x : x; // abs(x)
(x ^ (x >> 31)) - (x >> 31) // abs(x)

// Equal sign check (both ints are pos or neg)
a ^ b >= 0; // a * b > 0

// Rounding, ceiling, flooring
(x + 0.5) >> 0; // round(x)
(x + 1) >> 0; // ceil(x)
x >> 0; // floor(x)

Hot pastes

free anonymous socks5 proxies
     24837 | Never
free anonymous http proxies
     23288 | Never
maze traversal
     2626 | Never
hello, world
     2228 | Never
difference between iter and into_iter in rust
     1769 | Never
bitwise operations
     1553 | Never
DEVISIB All-in-One Coffee Machine Espresso Coffee Maker with Grinder Automatic coffee makers
     453 | 2022-12-04
leetcode 739 Daily Temperatures python
     271 | Never
presentation on friendly interactive shell, fish
     227 | Never
leetcode 621 task scheduler python
     181 | Never