Bitwise OR calculator
5 OR 3 gives 7: in binary, 101 and 11 line up from the right and every column holding a 1 keeps it, giving 111. Enter two whole numbers to get their bitwise OR, exact and with no 32-bit truncation. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- A
- 5
- B
- 3
- Result
- 7
- Expression
- 5 | 3 = 7
- Binary a
- 101
- Binary b
- 11
Bitwise OR is the integer operation that sets a result bit wherever that bit is already set in either operand, or in both. Developers write it with a vertical bar in C, Java, JavaScript, Python, Go, and most assembly dialects whenever they merge permission flags, pack feature bits, or combine hardware register masks. Students meet the same operator when they convert two decimals to binary, line the bits up from the least significant end, and write a one in every column that already contains a one. This calculator accepts two integers, evaluates their inclusive bitwise OR with exact integer arithmetic rather than a language's thirty-two-bit truncation, and returns the resulting integer together with binary views of both inputs and the answer so the column rule can be checked by eye.
What bitwise OR does to each bit
Bitwise OR, written with a vertical bar in C, Java, JavaScript, Python, and most assembly languages, builds a result integer whose bit at position k is one whenever the bit at position k is one in the first operand, the second operand, or both. The rule is the inclusive disjunction of two bits: zero or zero is zero; every other combination is one.
That is different from exclusive or, which turns a bit off when both sides already have it, and different from logical or, which collapses each operand to a single true-or-false value instead of walking the bit vector. A worked decimal pair makes the column rule concrete. Five in binary is one-zero-one and three is one-one; lining those bits up from the least significant end gives one-one-one, which is seven.
Twelve is one-one-zero-zero and ten is one-zero-one-zero; the column-wise inclusive or is one-one-one-zero, which is fourteen. The same identity is how flag words accumulate permissions: if read is bit zero and write is bit one, then read or write is the integer three. Hardware register maps, file-mode bits, and network protocol flags all use this merge-ones pattern.
Where a bitwise OR calculator earns its keep
Developers use a bitwise or calculator when they assemble permission masks, merge feature bits, or check that a constant in a header really is the inclusive combination they think it is. Embedded and protocol work often documents registers as hex dumps; converting two integers, or-ing them, and reading the binary fields back is faster than opening a debugger for a one-off.
Computer-science courses introduce bitwise or in the same week as and, xor, and shifts; a deterministic oracle lets a learning platform mark both the decimal answer and the bit string without executing untrusted student code. Invalid input does not consume balance. Large operands such as two to the fortieth or one stay exact here; a thirty-two-bit language operator would drop those high bits and return a wrong one, which is exactly the class of silent bug this contract is written to prevent.
What you can do with it
Permission and feature-flag masks
Merge two integer flag words (read or write, feature A or feature B) and read back the decimal result plus binary bits to confirm the union.
Classroom bitwise homework
Let students submit two integers and check both the decimal a | b and the binary column rule against a deterministic oracle that rejects non-integers.
Register and protocol constants
Verify that a documented hardware or protocol mask is the inclusive OR of two listed fields without opening a debugger or relying on 32-bit truncation.
FAQ
What happens if an input is not an integer?
Floats, text, booleans, missing values, and non-finite numbers are rejected and are not billed.
Is this the same as JavaScript's | operator?
The bit rule is the same, but this calculator uses unlimited-width integer OR. Language | often truncates to thirty-two bits, so 2^40 | 1 would wrongly become 1 there and stays exact here.
Does bitwise OR work with negative integers?
Yes. Signed values use two's-complement inclusive OR. The result is a safe integer; binary fields show a leading minus for negatives.
How is bitwise OR different from XOR and from logical OR?
Bitwise OR keeps a 1 wherever either number has one, including where both do. XOR turns that shared bit off instead, and logical OR treats each whole number as a single true or false value rather than comparing bit by bit.
How do I combine permission flags with OR?
Give each permission its own bit and OR them together. If read is bit 0, worth 1, and write is bit 1, worth 2, then read OR write is 3, a single number that carries both permissions.
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/math/or \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"a":5,"b":3}'const res = await fetch("https://api.kit.forhosting.com/math/or", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"a": 5,
"b": 3
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/math/or",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"a": 5,
"b": 3
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/math/or", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"a":5,"b":3}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"a":5,"b":3}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/math/or", 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": 5,
"b": 3
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "math.or",
"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.
Limits
max_abs | 9007199254740991 |
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
Either operand that is not a finite integer is rejected with invalid_input instead of being silently floored.
What bitwise OR does to each bit
This endpoint applies that definition to two integers and returns the merged integer; it does not interpret named flags for you, and it does not truncate the operands to thirty-two bits the way a raw language operator often does when the high bits sit above a machine word.
Input contract, output shape, and validation
The implementation never silently floors a float: sending five point five is an error, not a coerced five, which prevents the classic bug where a language bitwise operator truncates toward zero and still returns a number. Failed validation is not billed. POST a JSON object with two required integers, a and b. Each field may arrive as a JSON number or as a decimal integer string, including an optional leading sign. Aliases x or left are accepted for a, and y or right for b; the canonical names still appear in the response. Missing fields, empty strings, booleans, objects, non-numeric text, infinities, and any value that is not a finite integer fail with invalid_input and name the offending field, so a form renderer can highlight the control. Values outside the safe-integer range are also rejected because the JSON number type cannot represent them exactly. On success the body echoes a and b, returns result as the integer bitwise-or of the pair, includes an expression string such as five vertical-bar three equals seven, and includes binary_a, binary_b, and binary_result so you can audit the column rule without a second conversion step. The arithmetic uses unlimited-width signed two's-complement or via BigInt, then converts back to a JSON number that is guaranteed to stay inside the safe-integer range because both inputs were already inside that range. Pair the JSON with your own UI if you want named flag labels; this capability only computes the integer operation.
Where a bitwise OR calculator earns its keep
Data pipelines that pack categorical flags into a single integer can call the API from any language that speaks JSON instead of reimplementing two's-complement width rules in every runtime.
Technical questions
How do I compute the bitwise OR of two integers?
Send integers a and b (or aliases x/left and y/right). The API returns result = a | b, an expression string, and binary views of both operands and the answer.
What does the bitwise OR calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.