Contact

BITAND Function in ONLYOFFICE Spreadsheet Editor: Syntax and Practical Examples

Engineering Intermediate ONLYOFFICE Spreadsheet Editor

Bitwise AND lets a mask keep only the flags shared by two nonnegative values; it is often used to check whether permissions or device status fields contain a requested flag. Learn official syntax, reproducible worksheet examples, advanced applications, and verification limits.

Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in ONLYOFFICE Spreadsheet Editor. How formula examples are checked

Quick answer

Keep the bit positions that are on in both decimal integer masks. The exact current English ONLYOFFICE formula signature is =BITAND(number1, number2). The function belongs to the Engineering category of ONLYOFFICE Spreadsheet Editor. Both parameters are required; there is no optional parameter or documented default. This syntax and the rule below come from the official ONLYOFFICE BITAND reference (checked 2026-10-13 UTC).

Verification: Worksheet and advanced results were independently calculated using exact integer arithmetic. Native ONLYOFFICE Docs or Desktop execution, localized input and historical-version compatibility were not tested.

What the function does, and when to use it

Bitwise AND lets a mask keep only the flags shared by two nonnegative values; it is often used to check whether permissions or device status fields contain a requested flag.

Official bit rule: A result bit is 1 only when the corresponding bit in both inputs is 1. The vendor notes establish that operational description. They do not provide a complete specification of all width, overflow, coercion, locale, or legacy-version behaviors.

Bitwise operators compare binary positions rather than truth values of entire cells. For example, decimal 12 is binary 1100β‚‚ while decimal 10 is 1010β‚‚, so their bit positions can be compared individually. BITAND(12,10) is mathematically 8, represented as 1000β‚‚.

If you need to combine flags, BITOR adds all present bits; BITXOR highlights changed bits. BITAND keeps shared bits. All three are numerically distinct operations.

Understand the binary bits without typing binary literals

A bit is 0 or 1. The places in a binary numeral are valued at 1, 2, 4, 8, 16, 32, and so on from the rightmost place. As a result, 1100β‚‚ is 12 decimal, whereas 1010β‚‚ is 10 decimal. Subscript β‚‚ in the article is a mathematical label; do not paste it into a formula argument. Input 12 as the number twelve; do not enter the text string "1100" expecting ONLYOFFICE to parse it as binary.

For a two-mask operation, BOTH inputs are ordinary nonnegative decimal numbers. Their binary representations are shown solely to help you check which positions match, differ, or are present.

Exact syntax, argument order, and types

=BITAND(number1, number2)
Position Argument Required? Official ONLYOFFICE type/rule Default
1 number1 Required number1 β€” required numeric value in decimal form, greater than or equal to zero. No default; must be supplied.
2 number2 Required number2 β€” required numeric value in decimal form, greater than or equal to zero. No default; must be supplied.

No argument is optional. The first argument goes first even if you change the order of source columns. The official reference supplies neither an optional-width argument nor an optional mode selector for BITAND. Do not add brackets to the formula: they are a documentation convention used for some other functions, but not part of this function’s documented signature.

Type distinction: Both inputs are displayed as decimal numbers. They are not binary strings: for example, decimal 10 corresponds to binary 1010β‚‚. The sample values are all whole, nonnegative decimal integers, so the vendor’s stated >=0 requirements are respected.

The official formula-insertion guide describes using the Home or Formula tab and the search in Insert Function. The individual function article supplies the formula signature and notes used here.

Step-by-step worksheet: 20 reproducible test rows

Use a clean worksheet so no earlier sample values or formulas change these cell references:

  1. In A1 type Scenario, in B1 type First decimal mask, in C1 type Second decimal mask, in D1 type BITAND formula result, and in E1 type Independent expectation. Keep inputs in B and C as numeric cells, not binary strings.
  2. Populate A2:C21 with the input columns in the table below. Each B and C cell must contain the decimal integer displayed in the table. Column C is the shift count for the SHIFT functions; otherwise it is the second mask.
  3. In D2, type =BITAND(B2,C2) and press Enter. Use the fill handle to copy the same relative formula down through D21. For the comparisons, put the corresponding expected numbers from the table into E2:E21.
  4. Optional manual review column F: put =D2=E2 in F2 and copy down; a TRUE result would show equality in your own installed edition. This step has not been executed here, so don’t interpret it as a passed native test.
  5. When a result differs, record the app and version, Docs vs Desktop, locale, input cell type, exact formula text, and any displayed error. Compare the vendor argument rules first. Save your workbook if you decide to run the separate native-validation phase.

Inputs and independently expected outputs

Row Scenario B (decimal) C (decimal) Expected D B in binary Expected D in binary
2 Both zero 0 0 0 0 0
3 First bit only 1 0 0 1 0
4 Same lowest bit 1 1 1 1 1
5 Small overlapping flags 5 3 1 101 1
6 Two four-bit values 12 10 8 1100 1000
7 Single shared high bit 15 8 8 1111 1000
8 Sparse masks 42 21 0 101010 0
9 Alternating bits 85 170 0 1010101 0
10 Keep upper nibble 255 240 240 11111111 11110000
11 Keep lower nibble 255 15 15 11111111 1111
12 Separated high/low bits 1024 1 0 10000000000 0
13 Twelve-bit versus byte 4095 255 255 111111111111 11111111
14 Wide alternating mask 65535 43690 43690 1111111111111111 1010101010101010
15 Decimal example 99 72 64 1100011 1000000
16 Disjoint neighbor fields 7 8 0 111 0
17 Almost same power of two 128 129 128 10000000 10000000
18 Complementary long masks 21845 43690 0 101010101010101 0
19 Top bit subset 1023 512 512 1111111111 1000000000
20 Different selected flags 72 40 8 1001000 1000
21 Overlapping byte fields 384 96 0 110000000 0

How to read the table: For every row, the independent calculation converted each B numeric input into binary, applied the documented bit position operation to nonnegative integral inputs, and converted the resulting binary integer back to decimal. The results are not a screenshot or native editor output.

Paste-ready formula checks

Formula typed into a spare cell Independent expected decimal value Result bits
=BITAND(0,0) 0 0
=BITAND(1,0) 0 0
=BITAND(1,1) 1 1
=BITAND(5,3) 1 1
=BITAND(12,10) 8 1000
=BITAND(15,8) 8 1000
=BITAND(42,21) 0 0
=BITAND(85,170) 0 0
=BITAND(255,240) 240 11110000
=BITAND(255,15) 15 1111

For a quick human cross-check, the example =BITAND(12,10) should produce 8 in the independent model, but this does not establish how untested versions calculate or format the result.

Advanced, practical applications

1. Detect a particular access flag

The decimal number 12 (1100β‚‚) represents flags 8 and 4. A mask of 4 (0100β‚‚) isolates the smaller flag.

  • Enter =BITAND(12,4). Independent expected result: 4, because 12 is 1100β‚‚, the other mask is 4 (100β‚‚), and the output is 100β‚‚.
  • Enter =BITAND(12,8). Independent expected result: 8, because 12 is 1100β‚‚, the other mask is 8 (1000β‚‚), and the output is 1000β‚‚.
  • Enter =BITAND(12,2). Independent expected result: 0, because 12 is 1100β‚‚, the other mask is 2 (10β‚‚), and the output is 0β‚‚.

The masked result is nonzero when at least one bit in the requested mask is present; to require all requested bits compare the result with the mask.

2. Keep a nibble from an integer

A lower-nibble mask of 15 (1111β‚‚) retains four low bits.

  • Enter =BITAND(171,15). Independent expected result: 11, because 171 is 10101011β‚‚, the other mask is 15 (1111β‚‚), and the output is 1011β‚‚.
  • Enter =BITAND(240,15). Independent expected result: 0, because 240 is 11110000β‚‚, the other mask is 15 (1111β‚‚), and the output is 0β‚‚.
  • Enter =BITAND(255,240). Independent expected result: 240, because 255 is 11111111β‚‚, the other mask is 240 (11110000β‚‚), and the output is 11110000β‚‚.

This is a numeric mask, not a text-substring operation.

3. Identify shared capability bits

Two devices can advertise decimal capability masks 42 (101010β‚‚) and 21 (010101β‚‚).

  • Enter =BITAND(42,21). Independent expected result: 0, because 42 is 101010β‚‚, the other mask is 21 (10101β‚‚), and the output is 0β‚‚.
  • Enter =BITAND(47,28). Independent expected result: 12, because 47 is 101111β‚‚, the other mask is 28 (11100β‚‚), and the output is 1100β‚‚.
  • Enter =BITAND(85,170). Independent expected result: 0, because 85 is 1010101β‚‚, the other mask is 170 (10101010β‚‚), and the output is 0β‚‚.

No overlapping 1 bits implies no shared flagged positions, but a zero alone does not tell you why the metadata differ.

Compare BITAND with other operations

Unlike AND(…), which is a logical truth-test function, BITAND performs a bitwise operation on corresponding positions of integer-like decimal values.

A few identities help detect mistakes before putting a bit mask in production. The following are mathematical rules on nonnegative integers, not a vendor-issued runtime promise about unlimited precision:

  • BITAND(a,b), BITOR(a,b), and BITXOR(a,b) are different ways to compare two masks: shared, any, and differing bits respectively.
  • a OR b = (a XOR b) + (a AND b) mathematically. This helps distinguish mask merging from regular decimal addition, which treats overlapping bits differently.
  • For nonnegative integer n and nonnegative count k, shifting left is n Γ— 2^k, while shifting right is the whole-number quotient of n Γ· 2^k; this relationship explains the examples but says nothing about the editor’s maximum supported width.
  • If you combine mask operations, keep the original decimal inputs in separate source columns. Do not overwrite raw device statuses, access codes or source measurements with computed flags; a conversion can hide which source contributed a bit.

Important note about leading zeros and signed values

A plain numeric cell stores a number, not a fixed-length binary string. Leading zeros may be meaningful in a hardware protocol but are not represented by these arithmetic examples. A negative signed integer uses representation conventions that are not specified in the checked BITAND reference. If your task needs a signed two’s-complement width, choose and document the protocol width separately and test the actual ONLYOFFICE version before claiming parity with another system.

Error conditions, documentation gaps and troubleshooting

The official BITAND help page specifies the allowed argument category and the bit rule, but it does not list a complete table of runtime error codes. The following problematic inputs are review cases, not errors observed in an editor. Never present #NUM!, #VALUE!, #NAME?, or a truncation rule as a verified result unless separately established from a relevant official source or native test.

Formula / diagnostic case What the official rule or reference establishes What still needs checking
=BITAND(-1,3) Vendor requires both inputs to be at least zero. Negative input violates the documented domain; exact error token not observed.
=BITAND(3.5,1) Vendor calls each argument a numeric decimal value but does not specify fraction handling. Do not assume flooring, coercion or a particular error code.
=BITAND("1010",3) Quoted text resembles a decimal number, not a declared binary string. Text-to-number coercion not verified; use numeric decimal source cells.
=BITAND(0,0) Documented nonnegative domain satisfied. Independent mathematical expectation: 0; verify if needed in an installed edition.
=BITAND(999999999999,1) No exact supported bit width or precision rule supplied by this help article. Avoid large-integer claims before native precision/range tests.

What to check if your result surprises you:

  1. Confirm BITAND is selected, rather than an adjacent name such as XOR, AND or OR with different semantics. The vendor lists this function under Engineering.
  2. Verify numeric input values in decimal, including negative signs, decimal fractions, empty cells, and pasted strings. The clean worked table uses only integral nonnegative numeric values.
  3. Verify argument order and exactly two comma-separated arguments in the English reference. The current formula UI instructions illustrate function insertion; locale-specific separators and labels must be checked in the target editor.
  4. For a shift, confirm that C2 is an integer count of binary positions, not a request for the number of output characters. For a mask operation, C2 is a second decimal mask, not a shift count.
  5. Prefer smaller sample integers while checking a version-specific maximum width. Exact overflow rules, boundaries and floating-point precision need native validation rather than assumptions borrowed from another spreadsheet.
  6. Preserve the formula, input types and installed build number in any issue report. No vendor error screenshots were captured; any formula returning a displayed error in a reviewer’s editor must be reported with that editor version before recording an exact error token.

Compatibility checks for your installation

  • Recreate each of the 20 safe rows in a specifically identified ONLYOFFICE Docs web version and record actual cell values.
  • Repeat selected boundary cases in a specifically identified Desktop Editors build, noting operating system and file format.
  • Check invalid negatives, fractions, blank/text cells and large values, and capture actual error tokens only after reproducible execution.
  • Check decimal separators, argument separators and localized function naming, using an actual non-English regional configuration.
  • Test save/reopen and export compatibility; an XLSX round-trip in another program would not alone establish that ONLYOFFICE executed the formula identically.

ONLYOFFICE platform, release, regional-language and compatibility notes

The guide is vendor-specific: ONLYOFFICE’s English Insert Functions catalogue lists this as an engineering function with its current unversioned online help. The same title does not establish a release-specific compatibility matrix or version of the calculation engine.

Web/Docs versus Desktop Editors: The official ONLYOFFICE Docs changelog lists Docs 10.0.0 released October 10, 2026. The separate Desktop Editors changelog lists Desktop Editors 9.4.0 released May 19, 2026 in its release history. The official Desktop GitHub release history also lists 10.0.0 released 13 October 2026. These pages are two different products’ release histories. Neither checked page identifies the first Docs or Desktop release supporting BITAND, and neither demonstrates a native execution of our examples. Treat old editions and shared XLSX compatibility as not verified, not automatically equivalent.

Formula syntax/locales: The examples use the English-language function spelling, an = prefix, the comma between two arguments shown in the official reference, and a period only in English explanatory numbers where needed. ONLYOFFICE offers additional Spreadsheet Editor advanced settings; do not assume this English formula can be pasted unchanged in every language or region. The function’s region-specific label and formula-argument separator were not tested in a running editor.

Validation boundaries: The vendor documents syntax and the basic operation; our mathematical verification confirms examples independently. Neither source type establishes installed behavior for fractions, negative counts, large bit widths, signed integers or cross-edition coercion. Those claims remain explicitly unverified.

The following links lead to official ONLYOFFICE references:

Sources and verification limits

  • Primary claim-level source: ONLYOFFICE BITAND reference β€” title, purpose, exact two-argument signature, argument conditions and bit-operation notes; inspected 2026-10-13 UTC.
  • Official UI context: Inserting functions and Advanced Settings; checked 2026-10-13 UTC.
  • Official release context: Docs changelog and Desktop changelog; checked 2026-10-13 UTC, with desktop/web differences explicitly unresolved.
  • Independent numerical verification: the examples were generated and cross-checked using Python exact integers and the algebraic relationships described above. a & b for BITAND, a | b for BITOR, a ^ b for BITXOR, a << k for left shift, and a >> k for right shift are used only as independent mathematical models on the safe nonnegative integral samples.
  • Missing verification: No native ONLYOFFICE execution (Docs or Desktop), no captured error messages, no screenshot, no localized editor run, no historical-version compatibility testing.

Last official source check: 2026-10-13 UTC. Guide research status: official-reference checked; independently calculated; native editor execution not performed.