The Bitwise Calculator performs AND, OR, XOR, NOT, left shift, and right shift operations on integers with simultaneous binary, decimal, hexadecimal, and octal output. Essential for embedded systems programming, network subnet masking, flag manipulation, and cryptographic operations.
—
1
0
1
0
1
0
1
0
1
1
0
0
1
1
0
0
—
—
—
—
—
—
—
—
—
1
0
1
0
1
0
1
0
1
1
0
0
1
1
0
0
—
—
—
—
—
—
—
—
Bitwise operations are the direct manipulation of individual bits in a binary number — the lowest-level operations a processor performs, executing in a single clock cycle and forming the foundation of everything from network address masking to cryptographic key generation. Understanding and calculating bitwise results is fundamental to embedded systems programming, kernel development, protocol implementation, and any domain where the bit-level representation of data matters. The bitwise calculator performs all standard bitwise operations with simultaneous multi-base output.
AND (&): result bit is 1 only if both input bits are 1. Primary use: masking — isolating specific bits while zeroing others. 0xFF & 0x0F = 0x0F (keeps lower 4 bits, clears upper 4). Checking if a bit is set: if (value & (1 << n)) tests whether bit n is 1.
OR (|): result bit is 1 if either input bit is 1. Primary use: setting bits — turning on specific bits without affecting others. value | (1 << n) sets bit n to 1 regardless of its current state.
XOR (^): result bit is 1 if the input bits differ. Primary use: toggling bits; detecting differences; simple encryption (applying the same key twice restores the original). value ^ (1 << n) toggles bit n.
NOT (~): inverts all bits (unary operation). In two's complement: ~x = -(x+1). ~0 = -1 in signed integers; ~0 = 0xFFFFFFFF in 32-bit unsigned.
Left shift (<<): shifts bits left by n positions, filling with zeros. Equivalent to multiplying by 2ⁿ. 5 << 3 = 40 (5 × 8). Overflow discards bits shifted past the register width.
Right shift (>>): shifts bits right by n positions. For unsigned: fills with zeros (logical shift). For signed: fills with the sign bit (arithmetic shift), preserving negative numbers. 40 >> 3 = 5 (40 ÷ 8). Use this online calculator for any bitwise operation. The binary arithmetic calculator handles arithmetic in binary.
Common bitwise idioms used in production code:
IP address subnetting is pure bitwise AND operation. Network address = IP address AND Subnet mask. For IP 192.168.1.50 (11000000.10101000.00000001.00110010) AND subnet mask 255.255.255.0 (11111111.11111111.11111111.00000000): network address = 192.168.1.0. The host portion = IP AND (NOT subnet mask) = IP AND 0.0.0.255: 0.0.0.50. This calculator makes subnet mask calculations transparent at the bit level. The binary arithmetic calculator and developer calculators cover the complete low-level programming toolkit.
Modern cryptographic algorithms are entirely composed of bitwise operations: AES uses XOR, bit rotations, and table lookups; SHA-256 uses AND, OR, XOR, NOT, and right rotations (ROTR) as its primary mixing functions; ChaCha20 uses only XOR, addition, and rotation. The exclusive use of bitwise operations (plus modular addition) in these algorithms ensures: constant-time execution (no secret-dependent branches), hardware implementation efficiency (bitwise gates are the fastest hardware circuits), and reversibility properties (XOR is its own inverse). Understanding bitwise operations is a prerequisite for reading cryptographic algorithm specifications.
The Result shows the decimal output of the selected bitwise operation. The bit-level display reveals the binary representation of both inputs (A and B) and the result, making it easy to verify the operation visually. For AND, a result bit is 1 only where both input bits are 1. For OR, a result bit is 1 where either input bit is 1. For XOR, a result bit is 1 where the input bits differ. Shift results show bits moved left or right with zero-fill.
Inputs
Results
170 (10101010) AND 204 (11001100) = 136 (10001000). Only positions where both have 1 remain.
Inputs
Results
255 (11111111) XOR 170 (10101010) = 85 (01010101). XOR flips the bits of A where B has 1s.
How helpful was this calculator?
5.0/5 (1 rating)