0x prefix, or binary with 0b).Bitwise operations work directly on the binary representation of integers — each bit is tested or modified independently. They are fundamental to systems programming, network masking, permission flags, graphics programming, and compression algorithms. This calculator shows the complete bit-level breakdown so you can see exactly how each operation changes individual bits.
AND (&) — a bit is 1 only if both inputs have 1 in that position. Used for masking: value & 0xFF extracts the low byte. OR (|) — a bit is 1 if either input has 1. Used for setting flags. XOR (^) — a bit is 1 if the inputs differ. Used for toggling bits and simple encryption. NOT (~) — flips all bits. Left shift (<<) — multiplies by powers of 2. Right shift (>>) — divides by powers of 2.
0xFF in binary is 11111111. ANDing any value with 0xFF zeros out all bits above the low 8, extracting just the least significant byte. This is the basis of all bitmask operations.
>> is an arithmetic right shift — it preserves the sign bit, shifting in 1s for negative numbers. >>> is a logical (unsigned) right shift — it always shifts in 0s, treating the value as unsigned.
JavaScript stores integers as 32-bit signed two's complement values. ~0 flips all 32 bits of 0 (all zeros) to all ones — which is -1 in two's complement signed representation.
Unix permissions are three 3-bit fields: owner, group, other. 7 = 0b111 (rwx), 5 = 0b101 (r-x). Each bit represents a permission flag — read (bit 2), write (bit 1), execute (bit 0).
See also the Binary to Decimal converter and Hex to Binary tool for number-base work.