BITOR Function (LibreOffice Calc)

Mathematical Beginner LibreOffice Calc Introduced in LibreOffice 4.0
math bitwise binary flags masking number-systems

The BITOR function performs a bitwise OR operation on two non‑negative integers. It is used for binary flag combination, mask construction, and low‑level numeric processing.

Compatibility

What the BITOR Function Does

  • Performs bitwise OR on two integers
  • Sets each bit to 1 if either input has a 1 in that position
  • Useful for flag combination, mask building, and binary encoding

Syntax

BITOR(number1; number2)

Arguments

  • number1:
    First non‑negative integer.

  • number2:
    Second non‑negative integer.

Basic Examples

Simple bitwise OR

=BITOR(6; 3)
→ 7

Because:

  • 6 = 110₂
  • 3 = 011₂
  • OR = 111₂ = 7

Using cell references

=BITOR(A1; B1)

Combine two flags

=BITOR(4; 8)
→ 12

Advanced Examples

Build a composite bit mask

=BITOR(BITLSHIFT(1; 3); BITLSHIFT(1; 5))

Add a flag to an existing mask

=BITOR(A1; FLAG)

Combine multiple flags

=BITOR(BITOR(A1; A2); A3)

Convert result to binary

=DEC2BIN(BITOR(A1; A2); 10)

Use with BASE for arbitrary‑width binary

=BASE(BITOR(A1; A2); 2; 16)

OR with a shifted value

=BITOR(A1; BITLSHIFT(A2; 4))

Edge Cases and Behavior Details

BITOR returns a non‑negative integer

Accepts:

  • Integers ≥ 0
  • Fractional inputs are truncated

Behavior details

  • If both inputs are 0 → result is 0
  • OR sets a bit to 1 if either input has a 1
  • Negative numbers are not allowed
  • Very large values may overflow internal bit width

Invalid input → Err:502

BITOR of an error → error propagates

Common Errors and Fixes

Err:502 — Invalid argument

Cause:

  • Negative numbers
  • Non-integer inputs
  • Non-numeric values

Fix:

  • Wrap with INT()
  • Ensure values ≥ 0
  • Validate numeric input

Unexpected large result

Cause:

  • OR combines all 1‑bits from both inputs

Fix:

  • Inspect binary using DEC2BIN

Best Practices

  • Use BITOR to combine flags and build masks
  • Use BITAND to test flags
  • Use BITXOR for toggling bits
  • Use DEC2BIN or BASE for debugging binary states
  • Validate inputs to avoid Err:502
BITOR is the cornerstone of flag systems — perfect for combining permissions, building masks, and assembling binary‑encoded values.

Related Patterns and Alternatives

  • Use BITAND for masking
  • Use BITXOR for toggling bits
  • Use BITLSHIFT and BITRSHIFT for shifting
  • Use DEC2BIN and BIN2DEC for conversions
  • Use BASE for arbitrary‑length binary workflows

By mastering BITOR and its companion functions, you can build powerful bitwise and binary‑processing workflows in LibreOffice Calc.

Copyright 2026. All rights reserved.