Skip to content
Jellykit

Bitwise Calculator

AND, OR, XOR, NOT, shifts and rotations on 8 to 128-bit integers, with the result in binary, hex, octal and decimal.

  • Runs on your device
Loading tool

About Bitwise Calculator

Enter one or two integers in decimal, hex (0x), binary (0b) or octal (0o), choose an operation and a bit width, and see the result in every base at once. The working is laid out bit by bit, so you can see exactly which bits a mask keeps or a shift moves.

The width matters: NOT, shifts and rotations depend on how many bits a value has, and negative numbers are stored in two’s complement within that width. The result is shown both unsigned and signed, so you can check what a C, Java or Rust integer of that size would hold.

How it works

  1. Both values are read as whole numbers and stored as the chosen number of bits. A negative value is written in two’s complement, so −1 in 8 bits is 0xFF.
  2. AND, OR and XOR combine the bits pairwise; NAND, NOR, XNOR and NOT flip every bit of the result within the width.
  3. A logical right shift fills with zeros; an arithmetic right shift copies the sign bit, as >> does on signed integers in C and Java. Rotations move bits that fall off one end back in at the other.
  4. All arithmetic uses JavaScript BigInt, so 64 and 128-bit values are exact.

Questions

Why do I need to choose a bit width?

NOT 5 is 250 in 8 bits but 4,294,967,290 in 32 bits. Operations that flip or move bits only have a single answer once you know how many bits there are, just as in a programming language’s fixed-size integer types.

What happens with a value that does not fit?

The calculator refuses it and tells you the range: for 8 bits, −128 to 255. It never cuts a number down silently, because that would hide the mistake.

How far can I shift?

From 0 up to the bit width. Shifting by the full width clears the value, or for an arithmetic shift of a negative number fills it with ones. Rotating by the full width gives the value back unchanged.

Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.