Contact

BITLSHIFT Function (LibreOffice Calc)

Mathematical Beginner LibreOffice Calc Introduction not established

The BITLSHIFT function performs a bitwise left shift on a non‑negative integer. It is used for binary manipulation, fast multiplication by powers of two, and low‑level numeric processing.

Verification status: Consult the documentation, examples and any stated test scope below. How formula examples are checked

Availability and version history

  • Introduced: Documented by LibreOffice 26.8.1.1; original introduction not established.
  • Availability: Supported in LibreOffice 26.8.1.1, verified against its function registry. This identifies a supported release, not a final working version.
  • Scope: Desktop Calc, using the English function name. Availability in other spreadsheet applications is separate.
  • Checked: 2026-10-14 — function reference; versioned support. Documentation/source check; not a new native test. Existing example-specific test claims below retain their stated scope.
The **BITLSHIFT** function performs a **bitwise left shift** on a non‑negative integer. Shifting left by *n* bits is equivalent to multiplying by 2ⁿ, making this function ideal for binary manipulation and fast arithmetic.

What the BITLSHIFT Function Does

  • Shifts bits left by a specified number of positions
  • Equivalent to multiplying by 2ⁿ
  • Useful for binary encoding, masks, and low‑level numeric workflows

Syntax

BITLSHIFT(number; shift)

Arguments

  • number:
    A non‑negative integer.

  • shift:
    Number of bits to shift left (integer; can be negative).

Basic Examples

Shift left by 1 bit (multiply by 2)

=BITLSHIFT(5; 1)
→ 10

Because 5 = 101₂ → 1010₂ = 10

Shift left by 3 bits (multiply by 8)

=BITLSHIFT(7; 3)
→ 56

Using cell references

=BITLSHIFT(A1; B1)

Advanced Examples

Convert result to binary

=DEC2BIN(BITLSHIFT(A1; 2); 10)

Use negative shift (equivalent to right shift)

=BITLSHIFT(16; -2)
→ 4

Build a bit mask

=BITLSHIFT(1; bit_position)

Combine with BITAND to extract fields

=BITAND(A1; BITLSHIFT(255; 8))

Combine with BITOR to assemble packed values

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

Use with BASE for arbitrary‑width binary

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

Edge Cases and Behavior Details

BITLSHIFT returns a non‑negative integer

Accepts:

  • Integers ≥ 0
  • Shift values can be positive or negative

Behavior details

  • Positive shift → left shift
  • Negative shift → right shift
  • Fractional inputs are truncated
  • Overflow may occur for very large shifts
  • Negative numbers are not allowed

Invalid input → Err:502

BITLSHIFT of an error → error propagates

Common Errors and Fixes

Err:502 — Invalid argument

Cause:

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

Fix:

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

Unexpected zero result

Cause:

  • Shift too large (all bits shifted out)

Fix:

  • Reduce shift value
  • Inspect binary using DEC2BIN

Best Practices

  • Use BITLSHIFT for fast multiplication by powers of two
  • Use negative shift values for right shifts
  • Combine with BITAND, BITOR, and BITXOR for full bitwise logic
  • Use DEC2BIN or BASE for debugging binary states
  • Validate inputs to avoid Err:502
BITLSHIFT is perfect for binary packing, bit masks, and efficient arithmetic — a core tool for low‑level numeric workflows.
  • Use BITRSHIFT for right shifts
  • Use BITAND, BITOR, BITXOR for bitwise logic
  • Use DEC2BIN and BIN2DEC for conversions
  • Use BASE for arbitrary‑length binary workflows

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