Category

Bitwise Calculator - AND, OR & XOR in Binary, Octal & Decimal

Perform bitwise AND, OR, and XOR operations on two numbers. Input in decimal, binary, or octal with a selectable bit width. Results shown in all bases plus a full bit-by-bit analysis table.

0 calculations

Calculation Parameters

e.g. 87 (decimal)
e.g. 101 (decimal)

Truth Table (AND / OR / XOR)

A B A & B A | B A ^ B
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0

Enter Parameters

Fill in the form on the left and click "Calculate"

What Is a Bitwise Calculator?

The bitwise calculator lets you execute bitwise AND, bitwise OR, and bitwise XOR (exclusive or) operations. This tool accepts numbers from the binary, octal, and decimal number systems and presents the result of the bitwise operation in all of those numeral systems (plus hexadecimal), together with a full bit-by-bit analysis table.

What Is a Bit? And What Is a Numeral System?

A bit is the smallest unit of information used in digital communication and electronics. Information is encoded in a logical state that can hold only two values: 1 or 0 — equivalently true/false, on/off, or yes/no. Since a single bit can only encode a very limited amount of information, bits are lined up to represent larger amounts of data. For example, one byte is a succession of 8 bits, equaling 28 = 256 logical states.

Most of us are not used to thinking in terms of bits when talking about numerical information, so let us compare binary numbers made from bits to our habitual decimal system:

  • The decimal system (base‑10) uses the digits 0 to 9. Every digit of a number corresponds to a power of the base 10. For example, 123 = 1×10² + 2×10¹ + 3×10⁰.
  • Binary numbers are based on base 2, so every digit corresponds to a power of 2. For example, the binary number 101 equals 1×2² + 0×2¹ + 1×2⁰ = 5 in the decimal system.

There are other popular numeral systems besides the binary and decimal ones — namely the octal system (base 8) and the hexadecimal system (base 16). Negative numbers are handled using the signed two's complement representation, the same method used across most processors and programming languages.

What Is a Bitwise Operator? AND, OR, and XOR

A bitwise operation is executed on a binary number, which can also be seen as a string of bits. Two input integers are written in binary format and compared bit by bit, position by position, from the first to the last. This calculator can perform three different bitwise operations:

  • Bitwise AND (&) — the corresponding bit of the result is 1 if both input numbers have a 1 in this position; otherwise it is 0.
  • Bitwise OR (|) — the corresponding bit of the result is 1 if at least one input number has a 1 in this position; otherwise it is 0.
  • Bitwise XOR / exclusive OR (^) — the corresponding bit of the result is 1 if one and only one input number has a 1 in this position; otherwise it is 0.

Truth Table

A B A & B A | B A ^ B
00000
01011
10011
11110

Bitwise operations are the base for numerous real-world applications, reaching from data compression and encryption over finite state machines to finding a network address from an IP address and a subnet mask.

How to Use the Bitwise Calculator

For example, we want to find the result of a bitwise AND for the numbers 87 and 101, both in the decimal system:

  1. Choose the number of bits in the binary representation. Since 8 bits allow for numbers between −128 and 127 in the decimal system, that is sufficient here.
  2. Choose your input datatype. The calculator supports numbers from the binary, octal, and decimal systems. We choose decimal.
  3. Input your data in fields Number A and Number B in the corresponding numeral system. The order of input — for us, 87 and 101 — does not matter for AND, OR, and XOR.
  4. Choose your bitwise operator from the options AND, OR, and XOR. We want the AND operator.
  5. The bitwise calculator presents your result as numbers from the binary, octal, decimal, and hexadecimal systems.

Example: 87 AND 101

  87 in binary:  0101 0111
 101 in binary:  0110 0101
 AND:            0100 0101  =  binary 0100 0101 · octal 105 · decimal 69

In case your binary result could be understood either as a negative number in signed notation or a positive number in unsigned notation, both decimal results are displayed.

Applications of Bitwise Logic

  • Masking & flags — AND extracts specific bits, OR sets them, and XOR toggles them without a full read-modify-write cycle.
  • Networking — AND with a subnet mask derives the network address from an IP address.
  • Cryptography — the XOR cipher (Vernam / one-time pad) and stream ciphers rely on XOR.
  • Error detection — parity bits and checksums are built from XOR.
  • Data compression & hashing — fast bit-level combinations of bytes and words.

Frequently Asked Questions (FAQ)

What is the difference between OR and XOR?

OR returns 1 when at least one input is 1 (including both). XOR returns 1 only when the inputs are different. When both inputs are 1, OR gives 1 but XOR gives 0.

What does bitwise AND do?

AND returns 1 in a position only when both inputs have a 1 there. It is commonly used to "mask off" (keep) only selected bits of a number.

Can I use negative numbers?

Yes. Enter a negative value in the decimal field and the calculator represents it using the signed two's complement of the chosen bit width, then applies the bitwise operation to that bit pattern.

How many bits should I choose?

Pick the smallest width that holds your numbers: 8 bits covers −128…127 (or 0…255 unsigned), 16 bits covers 0…65535, and 32 bits covers 0…4294967295. A wider setting simply pads the binary representation with leading zeros.

Does the order of the two numbers matter?

No. AND, OR, and XOR are all commutative, so A OP B always equals B OP A.

Calculation History

Loading...