BITLSHIFT in Calligra Sheets: Shift Integer Flags Left or Right
Shift integer masks by a documented bit count in Calligra Sheets, including negative shifts, worked tables, and safe limitations.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Calligra Sheets. How formula examples are checked
BITLSHIFT in Calligra Sheets
Quick answer
BITLSHIFT moves the binary digits of a whole number left by an integer count. For nonnegative small values, a left shift by one doubles the integer. =BITLSHIFT(3;2) has the independently checked expected result 12 (11 to 1100). A negative count reverses direction and shifts right, according to KDE documentation.
Exact syntax and argument order
=BITLSHIFT(number;shift_amount)
number is the required whole-number value whose bits move. shift_amount is the required integer number of positions; positive values shift left, zero leaves the number unchanged, negative values shift right. The official function registry sets exactly two parameters; there is no documented third argument or optional default. In the small nonnegative examples below, a left shift by n has the same mathematical value as multiplying by 2^n, provided significant bits are not lost or overflowed.
Evidence scope, release, locale and testing
Calligra’s English reference uses a semicolon (;) between parameters and ordinary decimal-point examples. Begin cell formulas with =. The notation here follows that documented English-language style. If a translated installation uses a different locale, check its function assistant and local number/separator conventions before copying formulas; this guide has not tested locale variants. The Calligra download page recommends Linux distribution packages or Flatpak and describes Windows as still being worked on. Other platforms and vendor builds were not tested. Function availability in the shipped source is not a promise about every installed package.
Step-by-step example: enter six input rows
Create a blank sheet. Put Number 1 (or Number) in A1, Number 2 (or Shift count) in B1, and Result in C1. Type these plain integers into A2:B7. In C2, type =BITLSHIFT(A2;B2) and fill down through C7. The table displays expected values from independent computation, not screenshots or observed app output.
| Row | A: Number | B: Shift count | C: Formula | Expected decimal | Binary explanation |
|---|---|---|---|---|---|
| 2 | 3 | 2 | =BITLSHIFT(A2;B2) |
12 | 11 shifted left 2 → 1100 |
| 3 | 5 | 1 | =BITLSHIFT(A3;B3) |
10 | 101 shifted left 1 → 1010 |
| 4 | 12 | 0 | =BITLSHIFT(A4;B4) |
12 | 1100 shifted left 0 → 1100 |
| 5 | 13 | -2 | =BITLSHIFT(A5;B5) |
3 | 1101 shifted right 2 → 11 |
| 6 | 1 | 4 | =BITLSHIFT(A6;B6) |
16 | 1 shifted left 4 → 10000 |
| 7 | 7 | 3 | =BITLSHIFT(A7;B7) |
56 | 111 shifted left 3 → 111000 |
A reproducible interpretation
Start with A2 = 3 (11 in binary) and B2 = 2. Moving the bits two positions to the left gives 1100, which is 12. At A5 = 13 (1101) and B5 = -2, negative shift direction turns the same call into a right shift, producing 11 (decimal 3).
A shift moves positions; it does not insert decimal zeros, round a number or calculate a percentage. When a right shift discards a 1-bit at the low end, reversing the shift will not recover that bit. For example, 13 shifted right twice becomes 3, and 3 shifted left twice becomes 12, not 13.
Advanced application: place a compact flag in a higher field
Suppose a four-bit status code is 6 (0110) in A2 and you reserve the lowest two bit positions for smaller flags. With B2 = 2, the formula
=BITLSHIFT(A2;B2)
has expected result 24 (11000 in binary). If the low field also contains a flag 1, combine them with the independently documented OR operation:
=BITOR(BITLSHIFT(A2;B2);1)
The expected combined value is 25 (11001). This is an educational illustration of packing two small fields, not a specification for real data serialization. To unpack the upper field, use =BITRSHIFT(25;2) with expected result 6. Restrict a production data format to a known fixed-width integer representation and explicitly verify larger values and negative numbers in each application.
Troubleshooting, errors and implementation limits
- Reversed count sign: A positive count shifts left;
=BITLSHIFT(13;-2)shifts right, so its expected result is 3, not 52. - Expecting decimal shift: Binary left shift of 3 by two places is 12, not 300.
- Using a decimal fraction or text: KDE’s XML describes both parameters as integers. It does not promise particular coercion or diagnostic wording for text, fractions, blanks or malformed references; use whole numbers to avoid ambiguity.
- Overflow or very large shift counts: The tagged C++ uses a 64-bit unsigned temporary and built-in shift operators, without specifying a spreadsheet-level maximum or overflow contract. Shifts at or beyond a machine-word width are not reliable portability test cases and may be undefined at the implementation level. Do not extrapolate the table to large counts; verify with an actual installed version first.
- Negative input number: The source converts the value through unsigned integer handling; two’s-complement-like effects may appear, but no consistent cross-application rule is established in the handbook. Stick to nonnegative test masks unless separately validated.
- Cell displays scientific notation or unexpected errors: Formatting can alter presentation. Check both cells’ values, leading
=, parentheses and the local argument separator before changing formulas. This guide has not observed a native Calligra error code.
Cross-software compatibility: Excel and LibreOffice Calc
Excel documents BITLSHIFT(number,shift_amount): nonnegative number not above 2^48-1, and an integer count with |shift_amount| <= 53. Negative counts reverse direction. Calligra documents the same conceptual negative-count reversal but does not promise Excel’s operand limits, overflow handling, errors or implicit conversions. The small examples are mathematically consistent in both environments. LibreOffice Calc executable compatibility was not checked. See Microsoft’s official BITLSHIFT documentation for its distinct product-specific constraints; never transplant those restrictions into a Calligra claim without evidence.
Official reference and verification
- Calligra Sheets — function documentation
- KDE Sheets function handbook
- BITLSHIFT C++ registration and implementation
- bit operations XML
Verification status: Official documentation checked; example outcomes were independently reasoned or arithmetically checked where applicable. Not executed in Calligra Sheets.
- No genuine Calligra Sheets screenshots are included; this guide does not use mock application images.