Skip to content
SoftwareSolutions.net
SEO, Website & Development

Bitwise calculator

Run AND, OR and XOR on two integers and see the binary result.

Try it

Ready

Inputs

Result

The result appears here as you type.

About Bitwise calculator

A bitwise calculator performs logical operations on the individual bits of two numbers. The common operations are AND, OR, XOR, NOT and bit shifts. Enter two whole numbers and choose an operation, and the calculator shows the result in decimal, binary and hexadecimal. Bitwise operations are used in programming for flags, masks, permissions, graphics and low-level control of hardware.

Results depend on the width of the numbers. The calculator treats values as unsigned integers within a fixed width, so check the width when you work with signed values or with a specific data format.

How to use Bitwise calculator

  1. Enter the first number in decimal, binary or hexadecimal.
  2. Enter the second number, where the operation needs two inputs.
  3. Choose the operation, such as AND, OR, XOR or a shift.
  4. Read the result in decimal, binary and hexadecimal.
  5. Check each bit position if you are debugging a mask or a flag.

AND, OR and XOR

AND returns 1 only where both bits are 1, which is useful for masking out bits. OR returns 1 where either bit is 1, which is used to set bits. XOR returns 1 where the bits differ, which is used to toggle bits and in simple encryption. For 1100 and 1010 in four bits, AND gives 1000, OR gives 1110 and XOR gives 0110.

A common pattern is a mask, a number whose bits select which positions to read or change. AND with a mask clears bits outside it, and OR with a mask sets bits inside it.

Shifts and NOT

A left shift moves bits to higher positions and multiplies by two for each shift. A right shift moves them lower and divides by two. NOT inverts every bit, which for unsigned values within a width is the same as subtracting the value from all ones.

Shifts can lose bits that move beyond the width, so check the result when the value is near the limit. In languages with signed shifts, the right shift of a negative number behaves differently, so confirm the rules for the language you use.

Frequently asked questions

What is a bitmask used for?

To select, set or clear specific bits in a number, such as flags for permissions or settings.

Does the calculator handle negative numbers?

It works with unsigned values within a width. For signed behaviour, combine it with the two's complement calculator.

Why show hexadecimal?

Hex is compact for binary data, and each hex digit maps to four bits, which makes patterns easier to read.

Related tools

Tools that pair well with this one.