Bitwise XOR

Compute the bitwise XOR (exclusive OR) operation between two integers. Free online binary calculator for digital logic, cryptography, and Boolean algebra.

Compute bitwise XOR

About This Calculator

The Bitwise XOR Calculator computes the bitwise exclusive OR (XOR) operation between two integers. For each bit position, the result is 1 if the corresponding bits of A and B differ, and 0 if they are the same. In boolean notation, this is expressed as A ⊕ B or A ^ B. The calculator displays results in both decimal and binary (0b prefix) formats for easy verification.

XOR is a fundamental operation in computer science and digital logic. It is used in cryptography (such as the XOR cipher and one-time pad), error detection (parity bits and checksums), graphics (bitmap masking and sprite rendering), and low-level programming for toggling specific bits. One well-known property is that XORing a value twice with the same key returns the original value, which makes it ideal for reversible encryption. XOR is also commonly used to swap two integer variables without using a temporary third variable, leveraging the property a ^= b; b ^= a; a ^= b; to exchange their values.

In digital electronics, the XOR gate is a fundamental building block used in adder circuits, comparators, and pseudo-random number generators (LFSRs). The operation is also called modulo-2 addition because the result bit is the sum of the input bits modulo 2. Understanding XOR is essential for students of computer science, electrical engineering, and anyone working with low-level data manipulation or encryption algorithms.

Frequently Asked Questions

How does the bitwise XOR calculator work?

Enter two integers A and B. The calculator computes the bitwise XOR (exclusive OR) operation (A ^ B) which outputs 1 for each bit position where the corresponding bits of A and B differ. The result is shown in both decimal and binary (0b) formats.

What is bitwise XOR used for?

Bitwise XOR is widely used in cryptography (symmetric encryption algorithms like XOR cipher), error detection (parity and CRC calculations), graphics programming (bitmap masking), and low-level bit manipulation. XOR is also commonly used to swap two variables without a temporary variable.

What is the truth table for XOR?

The XOR truth table shows: 0 XOR 0 = 0, 0 XOR 1 = 1, 1 XOR 0 = 1, 1 XOR 1 = 0. XOR outputs 1 only when the inputs differ, which is why it is called exclusive OR.

What is the difference between XOR and OR?

OR outputs 1 when at least one input is 1 (inclusive OR). XOR (exclusive OR) outputs 1 only when exactly one input is 1. For 1 XOR 1, the result is 0, whereas 1 OR 1 gives 1.

What is the difference between XOR and XNOR?

XOR (exclusive OR) outputs true when inputs differ. XNOR (exclusive NOR) is the complement of XOR -- it outputs true when inputs are the same. In other words, XNOR = NOT(XOR).

Is XOR commutative and associative?

Yes, XOR is both commutative (A XOR B = B XOR A) and associative ((A XOR B) XOR C = A XOR (B XOR C)). This makes XOR useful for multi-byte checksums and RAID parity calculations.

Can I share my XOR calculation?

Yes, the URL saves your input values so you can bookmark or share the exact calculation.

Is this XOR calculator free?

Yes, all calculators on Calculy are completely free to use with no registration required.