Calculate bitwise OR operation between two numbers
Calculate bitwise OR operations between two numbers instantly with our free online OR calculator. This tool helps programmers, students, and computer science professionals perform binary OR operations with visual bit-by-bit explanations. Simply enter two numbers and see the OR result in decimal, binary, and hexadecimal formats in real-time.
OR returns 1 when at least one bit is 1, returns 0 only when both are 0.
Bitwise OR calculator performs logical OR operation on binary numbers. Each bit pair is compared: 0 OR 0 = 0, all other combinations = 1. Essential for setting flags, combining bitmasks, and building permission sets.
Input two numbers. Calculator converts to binary, aligns bits, and performs OR on each position. A result bit is 1 if EITHER or BOTH corresponding input bits are 1. Only 0 OR 0 produces 0.
OR truth table: 0|0=0, 0|1=1, 1|0=1, 1|1=1. In programming: | operator. Used to: set bits, combine flags, create bitmasks. Result is at least as large as the larger input.
Turn on specific bits without affecting others.
flags | FLAG_ACTIVE sets the active bitMerge multiple permission sets into one.
Combine individual bit flags into a mask.
READ | WRITE | EXECUTEProvide defaults: value | default when value might be 0.
// Basic OR
console.log(12 | 10); // 14
// 1100 (12)
// 1010 (10)
// ----
// 1110 (14)
// Set a specific bit
const setBit = (n, pos) => n | (1 << pos);
setBit(0b1000, 1); // 0b1010 (set bit 1)
// Combine flags
const READ = 0b001;
const WRITE = 0b010;
const EXECUTE = 0b100;
const permissions = READ | WRITE | EXECUTE; // 0b111 (7)
// Set flag if condition
function setFlag(flags, flag, condition) {
return condition ? flags | flag : flags;
}OR outputs 1 if either input is 1. Use to set bits, combine flags, build masks.
Use bitwise OR to set specific bits, combine permission flags, build bitmasks, and any operation requiring selective bit setting.
OR with a mask having that bit set: value | (1 << n) sets bit n. Example: flags | 0x04 sets bit 2 regardless of its previous value.