ZenovayTools

Bitwise Calculator

Perform bitwise AND, OR, XOR, NOT, and shift operations on integers. View results in binary, hexadecimal, and decimal formats side by side.

0x0000003C · 0b111100

0x0000000D · 0b1101

60 & 13 = 12

A0000 0000 0000 0000 0000 0000 0011 1100
B0000 0000 0000 0000 0000 0000 0000 1101
=0000 0000 0000 0000 0000 0000 0000 1100

Decimal

12

Hexadecimal

0x0000000C

Binary (short)

0b1100

Bitwise Operation Truth Table
ABA & BA | BA ^ B~A
000001
010111
100110
111100

How to Use Bitwise Calculator

  1. 1Enter two integers (A and B) in decimal, binary (0b prefix), or hexadecimal (0x prefix).
  2. 2Select a bitwise operation: AND, OR, XOR, NOT, left shift, or right shift.
  3. 3View the result in binary, hexadecimal, and decimal representations.
Zenovay

Track your website performance

Real-time analytics, session replay, heatmaps, and AI insights. 2-minute setup, privacy-first.

Try Zenovay Analytics — Free

Frequently Asked Questions

What are bitwise operators?
Bitwise operators work on integers at the binary (bit) level. AND (&): output bit is 1 only if both input bits are 1. OR (|): output bit is 1 if either input bit is 1. XOR (^): output bit is 1 if exactly one input bit is 1 (exclusive or). NOT (~): flips every bit (1s complement); in JavaScript, NOT uses 32-bit signed integers so ~5 = -6. Left shift (<<): shifts all bits left by N places, equivalent to multiplying by 2^N. Right shift (>>): shifts right with sign extension; unsigned right shift (>>>): shifts right and fills with 0s.
What is a bitmask and how is it used?
A bitmask is an integer used with bitwise operators to set, clear, or test specific bits. Set a bit: value | (1 << n) sets bit n to 1. Clear a bit: value & ~(1 << n) clears bit n to 0. Toggle a bit: value ^ (1 << n) flips bit n. Test a bit: (value >> n) & 1 returns 1 if bit n is set. Practical uses: Unix file permissions (chmod 755 = 111 101 101 binary), IP subnet masks, feature flags packed into a single integer, RGB color channels, game state bitmaps, network protocol headers.
How does XOR work and what is it used for?
XOR (exclusive or) outputs 1 when bits differ. Key properties: A ^ A = 0, A ^ 0 = A, commutative and associative. Practical uses: simple encryption (XOR with a key to encrypt, XOR again to decrypt — same operation). Find the odd one out: XOR all numbers to find the unique one in an array where everything else appears twice. Swap without a temp variable: a ^= b; b ^= a; a ^= b. CRC (cyclic redundancy check) checksums for error detection. Parity bit calculation.
Why does JavaScript use 32-bit integers for bitwise ops?
JavaScript numbers are 64-bit IEEE 754 floats, but bitwise operators convert operands to 32-bit signed integers before operating. This means: the maximum safe value for bitwise ops is 2^31 − 1 = 2,147,483,647. Numbers above this overflow or produce unexpected results. NOT (~) always returns a 32-bit signed result — ~0 = -1, ~1 = -2. The unsigned right shift (>>>) returns an unsigned 32-bit integer. For 64-bit bitwise operations, use BigInt: 100n & 255n.
What are common bit manipulation tricks?
Check if a number is even: n & 1 === 0. Check if power of 2: n > 0 && (n & (n-1)) === 0. Get the lowest set bit: n & -n. Clear the lowest set bit: n & (n-1). Count set bits (popcount): while(n) { count += n & 1; n >>= 1; }. Swap nibbles in a byte: ((b & 0xF0) >> 4) | ((b & 0x0F) << 4). Fast floor division by power of 2: n >> k equals Math.floor(n / 2^k). Multiply by power of 2: n << k equals n * 2^k.