bit operation calculator

Auto mode reads decimal by default unless you use 0b or 0x prefixes.
  • All operations follow JavaScript bitwise rules (32-bit integers).
  • Shift amounts are normalized to 0–31.
  • Results are shown in signed decimal, unsigned decimal, binary, and hexadecimal.
Enter values, choose an operation, then click Calculate.

What this bit operation calculator does

This calculator lets you run common bitwise operations on integers and instantly inspect the result in multiple number systems. You can work in decimal, binary, or hexadecimal and switch between logical operators such as AND, OR, XOR, NOT, and bit shifts.

If you are learning low-level logic, debugging flags, or building software that manipulates packed data, tools like this save time and prevent mistakes.

Bitwise operators quick reference

AND (&)

Keeps a bit only when both A and B have that bit set to 1. Commonly used for masking and permission checks.

OR (|)

Sets a bit when either A or B has a 1. Useful for turning on feature flags without affecting other bits.

XOR (^)

Sets a bit when bits differ. Great for toggling bits and detecting changes.

NOT (~)

Flips all bits in A. In 32-bit two's complement, this is equivalent to -(A + 1).

Shift operators (<<, >>, >>>)

  • Left shift (A << n): moves bits left, filling with zeros from the right.
  • Signed right shift (A >> n): shifts right while preserving sign.
  • Unsigned right shift (A >>> n): shifts right and fills left side with zeros.

Why binary and hex views matter

Decimal is familiar, but bitwise logic is easier to verify in binary. Hexadecimal is a compact representation that maps cleanly to binary (each hex digit = 4 bits), making it ideal for registers, memory values, and masks.

Practical use cases

  • Feature flags: store many true/false settings in one integer.
  • Permissions systems: combine read/write/execute flags efficiently.
  • Graphics and color processing: extract and merge ARGB/RGB channels.
  • Network protocols: pack and unpack fields in headers.
  • Performance-sensitive logic: replace some arithmetic with bit operations where appropriate.

Important JavaScript note

JavaScript bitwise operators convert values to 32-bit signed integers internally. This means large numbers are truncated to 32 bits before operations are applied. That's expected behavior for bitwise logic in JS and is exactly what this calculator models.

Tips for reliable bit manipulation

  • Use explicit masks (for example, value & 0xFF) when extracting byte-sized chunks.
  • Choose descriptive constants for each flag rather than magic numbers.
  • Prefer hexadecimal for masks and register-style values.
  • Check signed vs unsigned interpretation when right-shifting.

Conclusion

Bit operations are foundational in systems programming, protocol design, and efficient data handling. With this calculator, you can quickly test expressions, compare representations, and develop confidence in your bit-level reasoning.

🔗 Related Calculators