Cookies This site keeps only what it needs to work. There is no analytics and no advertising on it today, and nothing here follows you to other sites. Read the privacy policy

Choose what to allow
+92 312 8299940Free Quote
Free tool, nothing to install

Bitwise Calculator
AND, OR, XOR, NOT And Shifts

This bitwise calculator runs AND, OR, XOR, NAND, NOR, XNOR, NOT, shifts and rotates on 8, 16, 32 and 64 bit numbers. See every bit in a row, and read the result in decimal, hex, octal and binary.

  • FreePrice
  • 12Operations
  • NoneSign-up
  • NoneUploads

Bitwise Calculator

AND, OR, XOR, NOT, shifts and rotates on 8 to 64 bit numbers

The bits
 
The result in every form
Binary
—
Decimal
—
Signed decimal
—
Hexadecimal
—
Octal
—
Bits set to one
—

Ready. Type a number for A.

Your browser does all of the work here, in this tab. We upload nothing, store nothing and log nothing.
The short version

What A Bitwise Calculator Does For You

Computers store every number as bits, which are ones and zeros. Bitwise operations work on those bits one at a time. They are small, fast and everywhere in code.

But bits are hard to picture. A bitwise calculator fixes that. First, type two numbers. Then pick an operation. The bits line up in rows, so you see what changed.

Also, you can type numbers in decimal, hex, binary or octal. So you can paste a mask from a datasheet or a flag from code, and get the answer in any form.

Everything runs in your browser. So nothing you type leaves your device.

How Bitwise Operations Work

A bitwise operation lines up two numbers and compares them bit by bit. For AND, a result bit is 1 only when both bits are 1. For OR, it is 1 when at least one bit is 1. For XOR, it is 1 when the bits differ.

Drawing of two binary numbers stacked on the left and an arrow to the result row on the right
Two rows of bits become one.

So 12 AND 10 gives 8. In binary, 1100 AND 1010 gives 1000.

For more detail, see: Wikipedia article on bitwise operations.

Bitwise AND

First, AND keeps only the bits that are set in both numbers. Use it to read a flag or to apply a mask. For example, a value AND 0xFF keeps the lowest eight bits.

Bitwise OR

OR sets a bit if either number has it set. Also, use it to switch a flag on, or to combine two masks into one.

Bitwise XOR

XOR sets a bit only when the two bits differ. Use it to flip bits, to compare two numbers, or to swap two values without a spare one. XOR with the same number twice gives back the start.

Bitwise calculator showing 12 XOR 10 in 8 bits with the bit rows and the result in every form
12 XOR 10 in 8 bits.

Then look at the bit rows in the tool. Each result bit sits under the two bits that made it.

NAND, NOR And XNOR

These three are the opposites of AND, OR and XOR. Each one runs the operation and then flips every bit. Chip designers love NAND and NOR, because either one can build every other gate.

Bitwise NOT

NOT flips every bit of one number. In 8 bits, NOT 0 gives 255. So the width matters, and you should pick it first. In 32 bits, NOT 0 gives 4294967295.

Shift Left

A left shift moves the bits toward the top and fills the gap with zeros. One step to the left doubles an unsigned number. So 3 shifted left by 2 gives 12.

Bits that fall off the top are lost. Then the tool shows what remains.

Shift Right: Logical And Arithmetic

A right shift moves the bits down. A logical shift fills the top with zeros. An arithmetic shift copies the top bit instead, so a negative number stays negative.

Then one step to the right halves a number and rounds down.

Rotate Left And Right

A rotate moves the bits like a shift, but the bits that fall off one end return at the other. So nothing is lost. Also, hashes and ciphers use rotates a lot.

Choose The Width

Pick 8, 16, 32 or 64 bits. The width sets how many bits NOT flips, where a shift loses bits, and how a number reads as signed.

A number too big for the width keeps only its lowest bits, and the tool tells you.

Signed And Unsigned Numbers

The same bits can mean two numbers. In 8 bits, 11111111 is 255 unsigned and -1 signed. The tool shows both, so you can pick the one your code uses.

Negative inputs use the standard two's complement form.

Type Numbers In Any Base

Choose decimal, hex, binary or octal for the box. You can also add a prefix, such as 0x for hex, 0b for binary and 0o for octal, and the prefix wins. Spaces and underscores do not count, so 1010 1111 works.

Common Uses

Programmers use bitwise operations for flags, masks, permissions, colour channels, packed data, hashes and fast maths. For example, a colour in 0xRRGGBB form keeps red in the top byte.

So shift right by 16 and AND with 0xFF to read it.

Check Your Code

Use the tool as a second opinion. Type the values from your code, run the same operation, and compare. So it helps you find an off by one shift or a wrong mask.

Safe By Design

First, the tool works in your browser. It sends nothing, and it stores nothing. So your numbers stay yours.

How it works

Using The Bitwise Calculator, Step By Step

Four steps take you from two numbers to a result.

  • 1

    Pick the operation

    Choose AND, OR, XOR, NOT, a shift or a rotate.

  • 2

    Pick the width

    Choose 8, 16, 32 or 64 bits to match your code.

  • 3

    Type your numbers

    Use decimal, hex, binary or octal, with or without a prefix.

  • 4

    Read the result

    See the bit rows, then copy the answer in the form you need.

Why this one

What This Bitwise Calculator Does Differently

It shows the bits, it matches real hardware, and it keeps your numbers private.

  • Twelve operations

    AND, OR, XOR, NAND, NOR, XNOR, NOT, three shifts and two rotates.

  • Bits in rows

    See each bit of A, B and the result lined up.

  • Real widths

    Work in 8, 16, 32 or 64 bits, exactly like a CPU.

  • Exact 64 bit maths

    Big numbers stay exact, with no rounding.

  • Every base

    Type and read decimal, signed, hex, octal and binary.

  • Nothing leaves your tab

    Your browser does the maths. We never see your numbers.

Good habits

Habits For Clean Bit Work

A few habits keep your bit maths right.

  • Pick the width first. NOT and shifts change with the width, so match your code.
  • Use hex for masks. Hex lines up with groups of four bits, so masks read easily.
  • Name your flags. Give each bit a name in your code, so a mask means something.
  • Use unsigned for bits. Signed numbers can surprise you on right shifts.
  • Mind the shift count. Shifting by the full width or more differs between languages.
  • Parenthesise. Bitwise operators rank below comparisons in many languages.
  • Test the edges. Try 0, the largest value and the top bit.
  • Check both readings. Look at the signed and the unsigned value of a result.
  • Write the mask in binary. A 0b prefix makes the intent clear.
  • Compare with your code. Run the same values here and in your program.
  • Keep it simple. A clear shift beats a clever trick that nobody can read.
Worth avoiding

Common Bitwise Mistakes This Tool Helps You Avoid

Each of these quietly breaks a mask.

  • Mixing up AND and OR

    AND keeps shared bits, and OR gathers all of them.

  • Forgetting the width

    NOT 0 is 255 in 8 bits and far bigger in 32 bits.

  • Signed right shifts

    An arithmetic shift copies the top bit, a logical one does not.

  • Shifting too far

    Bits shifted out are lost, and the count may wrap.

  • Logic instead of bitwise

    The symbol && is not the same as &.

  • Reading hex as decimal

    Pick the right base, or add a 0x prefix.

Questions

Bitwise Calculator Questions People Ask

Is this bitwise calculator free?

Yes. It costs nothing, needs no account and has no limits. It runs in your browser, so we have no server cost to pass on.

Do my numbers leave my device?

No. Your browser does the maths. Nothing reaches this site, and we keep nothing.

What is a bitwise operation?

It is an operation that works on the individual bits of a number, instead of on its whole value.

What does bitwise AND do?

It gives a 1 in each place where both numbers have a 1. So 12 AND 10 gives 8.

What does bitwise OR do?

It gives a 1 in each place where at least one number has a 1. So 12 OR 10 gives 14.

What does bitwise XOR do?

It gives a 1 in each place where the two numbers differ. So 12 XOR 10 gives 6.

What does bitwise NOT do?

It flips every bit of one number. The result depends on the width, so pick 8, 16, 32 or 64 bits first.

What are NAND, NOR and XNOR?

They are AND, OR and XOR followed by a NOT. Each one flips every bit of the plain result.

What does a left shift do?

It moves the bits up by the number of places you give, and fills the gap with zeros. Each step doubles an unsigned number.

What is the difference between a logical and an arithmetic right shift?

A logical shift fills the top with zeros. An arithmetic shift copies the top bit, so a negative number stays negative.

What is a rotate?

A shift where the bits that fall off one end come back at the other end. No bit is lost.

Which width should I pick?

Pick the width of the type in your code, such as 8 bits for a byte or 32 bits for an int.

What happens when a number is too big for the width?

The calculator keeps the lowest bits that fit, and a note tells you it did so.

How do negative numbers work?

They use two's complement. In 8 bits, -1 becomes 11111111, which is 255 unsigned.

How do I type hex or binary?

Pick the base in the box, or add a prefix: 0x for hex, 0b for binary and 0o for octal.

How do I turn decimal into binary here?

Type the number in A, pick any operation such as OR with 0, and read the Binary card.

What is a bitmask?

A number whose set bits mark the bits you care about. You combine it with AND, OR or XOR.

How do I check if a bit is set?

AND the number with a mask that has only that bit set. A result above zero means the bit is on.

How do I set, clear or toggle a bit?

Set it with OR and a mask. Clear it with AND and the NOT of the mask. Toggle it with XOR and the mask.

Can I swap two numbers with XOR?

Yes. XOR A with B, then B with A, then A with B again. The values trade places without a spare one.

Can it handle 64 bit numbers?

Yes. It uses exact big integers, so 64 bit values stay precise with no rounding.

Can I copy the result?

Yes. Pick a form in Copy as, such as hex or binary, and press Copy result.

Does it work on a phone?

Yes. The fields stack and the bit rows scroll. So you can check bits on the go.

More free tools

Handy Companions For Low Level Work

Bit maths is one step. These three tools help with the rest.

Ready To Calculate Some Bits?

Pick an operation, type your numbers, and read the bits. The calculator is free, needs no account, and keeps every number on your device.