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
| Operation | Meaning | Example |
|---|---|---|
| AND | 1 only when both bits are 1 | 1 & 0 = 0 |
| OR | 1 when either bit is 1 | 1 | 0 = 1 |
| XOR | 1 when bits are different | 1 ^ 1 = 0 |
| NOT | Flip each bit inside the selected width | ~0 = 1 |
| Left shift | Move bits left and fill right side with zero | 0011 << 1 = 0110 |
| Right shift | Move bits right; logical fills with zero, arithmetic can preserve sign | 1000 >> 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.