Bitwise XOR calculator
Combine two integers bit by bit with exclusive OR: 12 XOR 10 gives 6, because 1100 and 1010 differ in exactly two places. The result comes in decimal, binary and hex, with the count of differing bits. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- A
- 12
- B
- 10
- Result
- 6
- A binary
- 0b1100
- B binary
- 0b1010
- Result binary
- 0b110
Bitwise exclusive OR, written XOR or ⊕, is the digital-logic operation that sets each result bit to one only when the two input bits differ. Students of computer architecture, embedded engineers toggling flag bits, and reverse-engineering practitioners all need a fast, deterministic way to see what 12 XOR 10 equals in decimal, binary, and hex without opening a REPL. This bitwise XOR calculator accepts two safe integers, applies mathematical exclusive OR via arbitrary-precision two's-complement arithmetic, and returns the result together with binary and hexadecimal renderings plus a count of bits that differ (the Hamming distance of the magnitude).
What bitwise XOR means and why each bit flips independently
The exclusive OR of two bits is true when exactly one of them is true: zero XOR zero is zero, zero XOR one is one, one XOR zero is one, and one XOR one is zero. Extending that rule bit by bit across an entire integer yields the classic property that a XOR b has a one wherever a and b disagree and a zero wherever they agree.
In digital logic that maps to a gate with two inputs and one output; in programming languages it appears as the caret operator or as a named XOR instruction on the CPU. XOR is associative and commutative, and every value is its own inverse: a XOR a equals zero, and a XOR zero equals a. Unlike addition, XOR never produces a carry, so each bit lane is independent and the operation is cheap on every modern ALU.
This calculator reports the decimal result of a ⊕ b, shows binary and hex strings for both operands and the result so you can audit bit columns by eye, and counts how many bits differ so you can measure Hamming distance without a second tool. Negatives are handled with two's-complement integer XOR, matching mathematical BigInt exclusive OR rather than truncating to a fixed 32-bit machine word, which matters when values exceed the range of a language's 32-bit bitwise operators.
Where a bitwise XOR calculator earns its keep
Embedded firmware and device-driver work constantly toggles control bits with XOR masks: clear a flag by XORing the same mask twice, or flip a GPIO shadow register without disturbing neighboring bits. Network and storage code still uses running XOR for simple parity, RAID-style reconstruction sketches, and lightweight integrity checks where a cryptographic hash would be overkill. Computer-science courses introduce exclusive OR when teaching truth tables, Hamming distance, and CRC precursors; a live bitwise XOR calculator lets students check homework for arbitrary pairs without hand-drawing eight columns of zeros and ones.
Security and reverse-engineering notes often recover a single-byte XOR keystream by XORing ciphertext with known plaintext; having a deterministic oracle that matches BigInt semantics avoids the trap of 32-bit sign extension that differs across languages. Content sites that rank for bitwise XOR calculator benefit from a free browser path whose answers match the paid automation path byte for byte on the same pure module.
What you can do with it
Firmware flag and mask toggles
Compute status XOR mask for register updates, verify that applying the same mask twice restores the original value, and document bit layouts in driver notes.
FAQ
What is the truth table for XOR?
0⊕0=0, 0⊕1=1, 1⊕0=1, 1⊕1=0. Each result bit is 1 only where the two operands differ; that is the exclusive OR used in digital logic.
Does XOR work with negative numbers?
Yes. The calculator uses two's-complement integer XOR via BigInt semantics, so negatives are valid safe integers and results match mathematical exclusive OR.
How do I flip a single flag bit with XOR?
Combine the value with a mask that has a one only in that position. The flag flips while neighbouring bits stay untouched, and applying the same mask a second time brings the original value back.
What does the count of differing bits tell me?
It is the Hamming distance: the number of bit positions where the two values disagree. For 12 and 10 it is two, which also equals the number of ones in the result.
How is XOR different from ordinary addition?
XOR never carries into the next bit, so every bit column is handled on its own. That independence is why it is cheap in hardware and handy for parity and simple checks.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/elec/bitwise-xor \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":12,"b":10}'const res = await fetch("https://api.kit.forhosting.com/elec/bitwise-xor", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 12,
"b": 10
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/elec/bitwise-xor",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 12,
"b": 10
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/elec/bitwise-xor", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":12,"b":10}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":12,"b":10}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/elec/bitwise-xor", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"a": 12,
"b": 10
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "elec.bitwise_xor",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
Failed validation is not billed; every successful call costs the published $0.002 base price.
What bitwise XOR means and why each bit flips independently
Those identities make XOR the natural tool for toggling a bit mask (status equals status XOR flag), for simple parity and checksums (running XOR of payload bytes), and for in-place swap tricks that still show up in interview questions and low-level drivers.
Input contract, response shape, and error behaviour
Example: a equals twelve and b equals ten yields result six, because in binary 1100 XOR 1010 is 0110. POST a JSON body with two required integer fields: a (first operand) and b (second operand). Each field may arrive as a JSON number or as a numeric string in decimal, or with a 0x, 0b, or 0o prefix for hex, binary, or octal. Values must be finite safe integers within plus or minus Number.MAX_SAFE_INTEGER; fractional numbers, Infinity, NaN, empty strings, and missing fields fail with invalid_input naming the field, and those failures are not billed. Optional aliases x or left or first map to a, and y or right or second map to b, so callers can match the naming in their own code. On success the body echoes a and b as numbers, returns result as the exclusive OR, provides a_binary, b_binary, and result_binary strings with a 0b prefix (a leading minus for negative magnitudes), provides a_hex, b_hex, and result_hex with a 0x prefix, reports bits_differ as the population count of the magnitude of the result, and includes a short operation string such as twelve XOR ten equals six plus a formula restating that each bit is one where the operands differ. Pair the response with your own bitboard or register visualizer if you need animated bit lanes; this endpoint computes the integer XOR only and does not emit diagrams or multi-step classroom prose beyond the formula field.
Integration use cases
Classroom truth tables and Hamming distance
Let students submit two integers and check the exclusive-OR result, binary columns, and bits_differ count against hand-worked solutions.
Parity, checksums, and simple crypto drills
Build running XOR parity over buffers, recover single-byte XOR keys in CTF write-ups, and unit-test language-agnostic integer XOR fixtures.
Technical questions
How do I compute the bitwise XOR of two integers?
Send safe integers a and b (JSON numbers or numeric strings, including 0x/0b/0o). The API returns result = a ⊕ b plus binary and hex views and bits_differ.
What is bits_differ?
It is the population count of the magnitude of a XOR b—the number of bit positions that differ, also called Hamming distance for non-negative values.
What does the bitwise XOR calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.