bitwise calculator

32-bit Bitwise Calculator

Enter values in decimal, binary (0b...), hexadecimal (0x...), or octal (0o...).

For shifts, JavaScript uses only the lower 5 bits of B (B mod 32).
Enter values and click Calculate.

What is a bitwise calculator?

A bitwise calculator performs operations directly on the binary representation of integers. Instead of arithmetic like addition or multiplication, bitwise logic compares or shifts individual bits (0s and 1s). This is useful for low-level programming, optimizing performance, handling flags, and understanding how data is actually stored in memory.

Supported operations in this tool

1) AND (&)

Returns 1 only when both bits are 1. Common use: masking values to keep specific bits and clear others.

2) OR (|)

Returns 1 when either bit is 1. Common use: setting flags in permission systems or configuration masks.

3) XOR (^)

Returns 1 when bits differ. Useful for toggling bits, detecting differences, and some simple cryptographic tricks.

4) NOT (~)

Flips every bit: 1 becomes 0, and 0 becomes 1. In JavaScript, bitwise NOT operates on signed 32-bit integers.

5) Left and right shifts (<<, >>, >>>)

  • Left shift moves bits left, filling right side with 0s.
  • Signed right shift preserves sign bit for negative values.
  • Unsigned right shift always fills left side with 0s.

Input formats and examples

This calculator accepts multiple input styles so you can work naturally:

  • Decimal: 255
  • Binary: 0b11111111
  • Hexadecimal: 0xFF
  • Octal: 0o377

Results are shown as signed decimal, unsigned decimal, hexadecimal, and full 32-bit binary output.

Why signed vs unsigned matters

JavaScript bitwise operators convert values to 32-bit integers. That means large values wrap around, and the top bit (bit 31) acts as the sign bit for signed results. For this reason, the same bit pattern can represent different numbers depending on interpretation:

  • Signed: range from -2,147,483,648 to 2,147,483,647
  • Unsigned: range from 0 to 4,294,967,295

Practical uses of bitwise operations

Feature flags and permissions

Pack many true/false options into a single integer. Turn bits on with OR, off with AND + NOT, and test with AND.

Networking and protocols

Parse packet headers and status bytes where each bit has a specific meaning.

Graphics and embedded systems

Manipulate color channels, hardware registers, and packed binary structures efficiently.

Tips for accurate results

  • Remember: bitwise math in JavaScript is always 32-bit.
  • For shift operations, only B % 32 is used.
  • Use 0x for hex and 0b for binary to avoid confusion.
  • When debugging, compare both binary and hexadecimal output.

Final thoughts

Bitwise operations can feel intimidating at first, but once you visualize values as bit patterns, they become precise and predictable. Use this calculator as a quick lab: test ideas, verify masks, and build intuition for low-level logic one bit at a time.

🔗 Related Calculators