BITLSHIFT Function (LibreOffice Calc)

Mathematical Beginner LibreOffice Calc Introduced in LibreOffice 4.0
math bitwise binary shifting number-systems encoding

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.

Compatibility

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.

Related Patterns and Alternatives

  • 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.

Copyright 2026. All rights reserved.