loot.tools

Bitwise Calculator

Do bitwise math without second-guessing how your language handles it. Enter two integers in decimal, hex (0x), binary (0b), or octal (0o), pick an operation - AND, OR, XOR, NAND, NOR, XNOR, NOT, or a left/right shift - and read the result in binary, hex, decimal, and octal at once. Choose an 8-, 16-, 32-, or 64-bit width and everything is masked to that register size, so NOT and shifts behave exactly like they would in fixed-width code. It uses BigInt under the hood, so 64-bit values stay exact. Runs entirely in your browser.

Run AND, OR, XOR, NOT, and shifts on two integers and see the result in binary, hex, decimal, and octal. Enter values in decimal, hex (0x), binary (0b), or octal (0o). Everything is masked to the bit width you pick, so NOT and shifts behave like a real fixed-width register.

Bit width
0000 1100
0000 1010
A AND B (8-bit)
Binary
0000 1000
Hex
0x08
Decimal (unsigned)
8
Decimal (signed)
8
Octal
0o10

What bitwise operations do

Bitwise operators line up two numbers bit for bit and combine them one column at a time. AND keeps a bit only when both inputs have it set, OR sets it when either does, and XOR sets it when exactly one does. NOT flips every bit. Shifts slide the bits left or right, which multiplies or divides by powers of two. These are the building blocks behind flags, masks, permissions, and a lot of low-level encoding.

Why bit width matters

NOT and the shifts only make sense against a fixed number of bits. NOT 5 is a different value in an 8-bit byte than in a 32-bit word, because the leading zeros that get flipped depend on how wide the register is. Pick 8, 16, 32, or 64 bits and every result is masked to that width, so what you see matches what your code would compute. The result also shows both an unsigned and a signed (two's-complement) reading of the same bits.

When this helps

  • Building or checking a permission or feature-flag bitmask
  • Reading a hardware register where each bit means something
  • Working out what a shift does to a value before you write it
  • Confirming a hash or checksum step that mixes bits with XOR
  • Teaching or learning how two's complement and shifts actually work, with binary you can read at a glance