bitwise or calculator

Bitwise OR Calculator (32-bit)

Enter two integers and calculate A | B. You can type decimal values, or use prefixes like 0b (binary) and 0x (hex).

Enter two numbers and click Calculate OR.

Note: JavaScript bitwise operators work with 32-bit integers. Values outside that range are truncated to 32 bits.

What Is a Bitwise OR Operation?

A bitwise OR compares two numbers one bit at a time. For each bit position, the output is 1 if either input bit is 1. The output is 0 only when both bits are 0.

OR truth table

  • 0 OR 0 = 0
  • 0 OR 1 = 1
  • 1 OR 0 = 1
  • 1 OR 1 = 1

In many programming languages (including JavaScript, C, C++, Java, and others), this operation is written as |.

Quick Example

Suppose you OR the numbers 12 and 10:

  • 12 in binary is 1100
  • 10 in binary is 1010
  • 1100 | 1010 = 1110
  • 1110 in decimal is 14

So, 12 | 10 = 14.

Why Use a Bitwise OR Calculator?

Bitwise operations are powerful but easy to misread by eye, especially with long binary values. A calculator helps you:

  • Check low-level programming logic quickly
  • Combine bit flags safely
  • Validate results when debugging binary masks
  • Convert between signed, unsigned, binary, and hexadecimal views

Common Real-World Use Cases

1) Combining feature flags

If each bit represents a feature, OR lets you enable multiple features in one value.

Example: if READ = 1 and WRITE = 2, then READ | WRITE = 3.

2) Building masks in systems programming

In embedded systems and hardware control, OR is used to set specific register bits without clearing others.

3) Networking and protocol parsing

Binary masks are often merged with OR when constructing packet fields and header values.

Input Formats Supported by This Tool

  • Decimal: 42
  • Binary: 0b101010
  • Hexadecimal: 0x2A

In Auto mode, prefixes are detected automatically. You can also force a format using the dropdown.

Signed vs Unsigned Results

This calculator displays both:

  • Signed decimal (32-bit two’s complement)
  • Unsigned decimal (0 to 4,294,967,295)

That makes it easier to reason about results used in different languages and APIs.

Troubleshooting Tips

  • If you see an error, check that your digits match the selected base.
  • For binary, use only 0 and 1.
  • For hex, valid digits are 0-9 and A-F.
  • If your number is very large, remember it will be truncated to 32 bits for bitwise math.

FAQ

Is this the same as logical OR?

No. Logical OR (||) works with truthy/falsy expressions. Bitwise OR (|) works directly on integer bits.

Can I use negative numbers?

Yes. Negative values are handled using 32-bit two’s complement representation.

Can I use this for learning?

Absolutely. Try different decimal, binary, and hex inputs to see how one operator changes all representations.

🔗 Related Calculators