05 // Unicode, Symbol & Encoding WorkbenchNUMBER-BASE-BITWISE
Bitwise AND, OR, XOR, NOT & Bit-Shift Calculator
Bitwise operators manipulate individual binary flags, subnet masks, RGB color channels, and cryptographic registers in a single CPU clock cycle.
DECIMAL (10)
240
HEX (16)
0xF0
BINARY (2)
0b11110000
OCTAL (8)
0o360
A & B
0 (0x0)
A | B
255 (0xFF)
A ^ B
255 (0xFF)
A << 1 / A >> 1
480 / 120
Was this tool helpful?
Reference Table
- 01`x & (x - 1)` clears the lowest set bit of `x` (hence `(x & (x - 1)) === 0` tests whether `x > 0` is an exact power of 2).
- 02`x ^ x === 0` and `(x ^ k) ^ k === x` form the basis of stream ciphers and parity checks.
Frequently Asked Questions
How do I test, set, clear, or toggle bit `k` of an integer `x`?+
Test: `(x >> k) & 1`; Set: `x | (1 << k)`; Clear: `x & ~(1 << k)`; Toggle: `x ^ (1 << k)`.
What is the difference between `>>` and `>>>` in JavaScript?+
`>>` is arithmetic sign-propagating right shift, whereas `>>>` is logical zero-fill unsigned 32-bit right shift.
Why does `1 << 31` return `-2147483648` in JS `Number`?+
Standard JS bitwise operators cast operands to signed 32-bit Two's Complement `Int32`; use `1n << 31n` (`BigInt`) for arbitrary-width bit shifts.