Bitwise Calculator
Result
A AND B 0
A OR B 30
A XOR B 30
Apply the bitwise AND, OR, and XOR operators to two integers. Enter two whole numbers and this calculator compares them bit by bit and returns each result in decimal.
Formula
AND = A & B, OR = A | B, XOR = A ^ B
- Each integer is compared bit by bit, and the chosen logical rule is applied to every pair of bits.
- AND outputs 1 only where both bits are 1, so it keeps the bits the two numbers share.
- OR outputs 1 where either bit is 1, so it combines the set bits of both numbers.
- XOR (exclusive OR) outputs 1 only where the two bits differ.
- Inputs are truncated to whole numbers and evaluated using 32-bit signed integer arithmetic.
10 with 20
Inputs
- Value A (integer): 10
- Value B (integer): 20
10 = 01010₂ and 20 = 10100₂. AND = 0 (no shared bits), OR = 30 (11110₂), XOR = 30 (11110₂).
Frequently asked questions
What is a bitwise AND?
It compares two numbers bit by bit and outputs 1 only when both corresponding bits are 1. It is often used to mask or test specific bits.
How is OR different from XOR?
OR outputs 1 when either bit (or both) is 1. XOR outputs 1 only when the bits differ, so two 1s give 0.
What are bitwise operations used for?
They power flags and permissions, masking, fast arithmetic tricks, hashing, and many low-level data-manipulation tasks.
Do these work on negative numbers?
Yes. The operators use 32-bit signed (two's-complement) representation, so negative inputs are handled the same way most programming languages do.
Why are my inputs rounded?
Bitwise operations are defined on integers, so any decimal part is truncated before the operation is applied.