Skip to content

Bitwise Calculator

Compute AND, OR, XOR, NOT and bit shifts on two integers.

Calculated locally in your browser.

How do you calculate bitwise operations on two integers?

AND keeps bits set in both numbers, OR keeps bits set in either, XOR keeps bits set in exactly one, NOT inverts all bits, and shifts move bits left or right. Operations use 32-bit integers, matching JavaScript and many languages. For example, 12 AND 10 = 8, 12 OR 10 = 14, and 12 XOR 10 = 6.

Understanding your result

Operations use 32-bit integers, matching how JavaScript and many languages handle bitwise maths.

Formula and method

AND keeps bits set in both, OR keeps bits set in either, XOR keeps bits set in exactly one, NOT inverts all bits, and shifts move bits left or right.

Assumptions and limitations

Operations run on signed 32-bit integers, exactly as JavaScript does, so values are wrapped to the range roughly minus 2.1 billion to 2.1 billion. Numbers beyond 32 bits, floating-point inputs and fractional shift amounts are truncated or reduced modulo 32. NOT and the sign-propagating right shift reflect two's-complement representation, which can surprise you with negative results.

Worked example

12 AND 10 = 8, 12 OR 10 = 14, 12 XOR 10 = 6.

How to use this tool

  1. Enter integer A (and optionally B).
  2. Read the result of each operation.

Common mistakes to avoid

  • Expecting unsigned results for NOT — ~12 is −13 in signed 32-bit.

About the Bitwise Calculator

Perform bitwise operations on two integers and see the result in decimal, binary and hexadecimal.

Who should use this tool

Programmers working with flags, masks and low-level logic.

Benefits

  • Shows each result in decimal, binary and hexadecimal together
  • Covers AND, OR, XOR, NOT and both shift operators
  • Matches JavaScript's 32-bit behaviour for predictable results
  • Works offline in the browser with no data sent anywhere

Practical use cases

  • Debugging bit flags and permission masks in code
  • Learning how two's-complement and shifts behave
  • Verifying hardware register values during embedded work
  • Checking XOR and masking logic before writing it

Explore all Mathematics tools

Frequently asked questions

What is the difference between >> and >>>?

>> keeps the sign bit (arithmetic shift); >>> fills with zeros (logical shift).

What bit width is used?

32-bit signed integers, as in JavaScript.

Why does NOT return a negative number?

Bitwise NOT inverts every bit under two's-complement representation, where the highest bit signals the sign. Inverting a small positive integer sets that top bit, producing a negative result: NOT 0 is minus 1, and NOT 5 is minus 6. This matches how signed 32-bit integers work in most programming languages.

Share this tool

Free to use — copy the link, share it anywhere, or add the tool to your own website.

Embed this tool on your site (free)

Copy this code and paste it into any web page — it stays free and always up to date: