Bitwise Operations Calculator

Calculate AND, OR, XOR, NOT, shifts, and rotations with fixed-width binary, decimal, hexadecimal, octal, and signed two's-complement output.

Share this tool

Shifts cannot exceed the selected width. Rotations wrap by width.

Unary operation

NOT uses only operand A and flips bits inside the selected width.

Quick Load:

Calculating bitwise result...

Ready to calculate

Choose an operation, enter fixed-width operands, then calculate the bitwise result.

What Are Bitwise Operations?

Bitwise operations work directly on the individual bits of an integer. They are common in systems programming, embedded registers, Unix permissions, graphics, compression, networking, and interview questions because they let developers set, clear, toggle, test, and move bits efficiently.

This calculator applies every operation inside an explicit fixed width. That matters because ~00001111 is not meaningful until the width is known. In 8-bit mode it becomes 11110000, while in 16-bit mode it becomes 111111110000 with additional leading ones.

Bitwise Operator Reference

OperationMeaningExample
AND1 only when both bits are 11 & 0 = 0
OR1 when either bit is 11 | 0 = 1
XOR1 when bits are different1 ^ 1 = 0
NOTFlip each bit inside the selected width~0 = 1
Left shiftMove bits left and fill right side with zero0011 << 1 = 0110
Right shiftMove bits right; logical fills with zero, arithmetic can preserve sign1000 >> 1

Why Bit Width Matters

Most programming languages run bitwise operations in a fixed integer width such as 8, 16, 32, or 64 bits. Values larger than the selected width are masked to the lower bits. The calculator shows that mask and warns when a value is truncated, which makes it easier to debug flags, registers, and integer casts.

Signed Two's Complement

Two's complement is the common signed integer representation used by modern CPUs. If the highest bit is set, the signed decimal view subtracts 2^width from the unsigned value. The bit pattern stays the same; only the interpretation changes.

Useful References

FAQ

What does bitwise AND do?

AND returns 1 at a bit position only when both input bits are 1. It is often used to mask or test flags.

What is XOR used for?

XOR returns 1 when bits differ, which makes it useful to toggle selected flags or compare bit patterns.

Why does NOT depend on width?

NOT flips every bit, so the number of available bits determines how many leading bits become 1.

Can I use hexadecimal values?

Yes. Use auto-detect with 0x prefixes or select hexadecimal explicitly.

Related Tools