Binary OR Operation

OR linking the bits of two integers

Bitwise OR Calculator

Bitwise OR Operation

This function performs a binary OR operation on the bits of two integers. The result bit is 1 when at least one of the input bits is 1.

Example: 8 (hex) = 8 (dec) = 1000 (binary)
Example: 4 (hex) = 4 (dec) = 0100 (binary)
Results of OR Operation
Binary:
Octal:
Decimal:
Hexadecimal:

OR Operation Visualization

Example: 8 OR 4 = 12
1st Number: 1 0 0 0 (8)
2nd Number: 0 1 0 0 (4)
OR Result: 1 1 0 0 (12)
C (hex) = 12 (dec)
OR Truth Table
A
B
A | B

0
0
0
0
1
1
1
0
1
1
1
1
OR Properties
  • Result is 0 only when both bits are 0
  • Result is 1 when at least one bit is 1
  • Commutative: A | B = B | A
  • Associative: (A | B) | C = A | (B | C)

Mathematical Foundations of Bitwise OR Operation

The bitwise OR operation is applied bitwise to the corresponding positions:

Mathematical Definition
\[C_i = A_i \lor B_i\]

For each bit position i, logical disjunction is applied

Bitwise Application
\[\text{Result} = A \Or B\]

Simultaneous OR operation on all corresponding bit pairs

OR Operation Formulas and Examples

General OR Formula
\[\text{OR}(A, B) = A \lor B\]

Bitwise OR operation of two binary numbers A and B

Step-by-Step Example: 8 OR 4

1st Number A: 8₁₀ = 1000₂

2nd Number B: 4₁₀ = 0100₂

Position: 3210 (from right)

OR Operation:

Position 3: 1 | 0 = 1

Position 2: 0 | 1 = 1

Position 1: 0 | 0 = 0

Position 0: 0 | 0 = 0

Result: 1100₂ = 12₁₀ = C₁₆

More OR Examples
15 OR 240:
A: 00001111₂ (15)
B: 11110000₂ (240)
Result: 11111111₂ (255)
7 OR 56:
A: 00000111₂ (7)
B: 00111000₂ (56)
Result: 00111111₂ (63)
Mathematical Properties of OR Operation
Commutative Law:
\[A \lor B = B \lor A\]

Order of operands is arbitrary

Associative Law:
\[(A \lor B) \lor C = A \lor (B \lor C)\]

Parentheses are arbitrary

Identity Element:
\[A \lor 0 = A\]

OR with 0 changes nothing

Idempotency:
\[A \lor A = A\]

OR with itself = original

OR Reference

Standard Example
8 OR 4 = 12 1000 | 0100 = 1100 8 + 4 = 12 (no carry)
OR Truth Table
A
B
A|B

0
0
0
0
1
1
1
0
1
1
1
1
Bitwise Operators

|: bitwise OR

&: bitwise AND

^: bitwise XOR

~: bitwise NOT

<<,>>: bit shift

Common Applications

Set bits: x | mask

Activate flags: status | flag

Combine masks: mask1 | mask2

Enable register: reg | enable

Bitwise OR Operation - Detailed Description

OR Operation Fundamentals

The bitwise OR is applied to the bit sequences of two integers. The bits at the same position are linked with a logical OR (logical disjunction). The respective result bit is 0 only if both bits are 0.

OR Rule:
• 0 | 0 = 0 (both bits are 0)
• 0 | 1 = 1 (at least one bit is 1)
• 1 | 0 = 1 (at least one bit is 1)
• 1 | 1 = 1 (both bits are 1)

Processing Logic

When one or both bits are 1, the result bit is set to 1. The OR operation is particularly useful for setting specific bits or combining bit patterns.

Processing Steps

1. Convert both numbers to binary representation
2. Process bit by bit from right to left
3. Apply OR operation to corresponding bit pairs
4. Convert result to desired format

Practical Applications

Bitwise OR operations are fundamental in digital logic and computer programming. They enable targeted bit setting, flag combination, and implementation of logical circuits.

Application Areas:
• Bit masks for flags and status
• Hardware register manipulation
• Logic circuits
• Data compression and filtering

Mathematical Properties

The OR operation follows important mathematical laws such as commutativity and associativity, making it a powerful tool in Boolean algebra.

Important Properties
  • Commutative: A | B = B | A
  • Associative: (A | B) | C = A | (B | C)
  • Identity element: A | 0 = A
  • Idempotent: A | A = A

Practical OR Operation Examples

Flag Combination

Scenario: Combine permissions

Read Flag: 100₂ (4)

Write Flag: 010₂ (2)

Result: 110₂ (6 = Read+Write)

Hardware Register

Scenario: LED control

Current: 10100000₂

New LEDs: 00001100₂

Result: 10101100₂

Bit Masks

Scenario: Data filtering

Data: 11010010₂

Mask: 00001111₂

Result: 11011111₂

Programming Tips
  • Flag constants: #define FLAG_A (1<<0)
  • Set multiple flags: flags |= (FLAG_A | FLAG_B)
  • Combine bit fields: result = field1 | field2
  • Check status: if (status & FLAG)
  • Apply masks: data |= mask
  • Performance: Bitwise ops are very fast


IT Functions

Decimal, Hex, Bin, Octal conversionShift bits left or rightSet a bitClear a bitBitwise ANDBitwise ORBitwise exclusive OR

Special functions

AiryDerivative AiryBessel-IBessel-IeBessel-JBessel-JeBessel-KBessel-KeBessel-YBessel-YeSpherical-Bessel-J Spherical-Bessel-YHankelBetaIncomplete BetaIncomplete Inverse BetaBinomial CoefficientBinomial Coefficient LogarithmErfErfcErfiErfciFibonacciFibonacci TabelleGammaInverse GammaLog GammaDigammaTrigammaLogitSigmoidDerivative SigmoidSoftsignDerivative SoftsignSoftmaxStruveStruve tableModified StruveModified Struve tableRiemann Zeta

Hyperbolic functions

ACoshACothACschASechASinhATanhCoshCothCschSechSinhTanh

Trigonometrische Funktionen

ACosACotACscASecASinATanCosCotCscSecSinSincTanDegree to RadianRadian to Degree