BITAND in WPS Spreadsheet: Apply Bitwise And to Integer Flags
Use BITAND in WPS Spreadsheet with original bit-mask examples, the documented 48-bit integer domain and explicit error rules.
Verification status: See the evidence and test scope described in this guide. How formula examples are checked
Quick answer: BITAND performs bitwise AND on two nonnegative decimal integers and returns a decimal integer. =BITAND(13,10) is expected to return 8. A result bit is 1 only when both input bits at that position are 1.
Syntax and accepted inputs
=BITAND(number1,number2)
Both arguments are required. The official WPS lesson requires integers from 0 through 281474976710655, inclusive; the upper limit is 2^48−1. Enter ordinary decimal integer values. The function interprets their bits internally; it does not return a string of binary digits.
A value such as decimal 13 corresponds to binary 1101. Entering the decimal number 1101 instead supplies a different integer, not a declaration that the digits are binary. Use a conversion function when the source data is genuinely binary text, and check that its signed convention is suitable.
Worked example: inspect every bit
- On a fresh worksheet, enter the number 13 in A2 and 10 in B2.
- Enter
=BITAND(A2,B2)in C2. - The independent expected result is 8. Display it as an ordinary number rather than a date or percentage.
- Check the four positions with weights 8, 4, 2 and 1:
| Weight | Bit in 13 | Bit in 10 | Bitwise AND result |
|---|---|---|---|
| 8 | 1 | 1 | 1 |
| 4 | 1 | 0 | 0 |
| 2 | 0 | 1 | 0 |
| 1 | 1 | 0 | 0 |
Sum the weights whose result bit is 1 to obtain 8. This is a position-by-position calculation, not arithmetic multiplication, addition or a Boolean TRUE/FALSE test. Leading zero positions above weight 8 contribute nothing in this example.
Practical application: flag values
A settings value of 13 has flags 1, 4 and 8 enabled. To check the flag with weight 4, use =BITAND(13,4), whose expected result is 4. For flag 2, =BITAND(13,2) gives 0. When checking a multi-bit requirement such as mask 12, compare the result with the entire mask: BITAND(13,12)=12 means both required bits are present. A merely nonzero result would only show that at least one required bit is present.
A mask does not count the enabled flags. BITAND(13,12)=12 retains weights 8 and 4; it does not return the count two. Document each weight’s meaning in a separate legend, and treat the output as a flag value rather than an ordinary quantity.
Boundary controls and documented errors
| Formula | Expected result | Explanation |
|---|---|---|
=BITAND(0,13) |
0 | Apply the operation to an all-zero input |
=BITAND(13,13) |
13 | Matching input positions |
=BITAND(281474976710655,1) |
1 | Inclusive 48-bit maximum |
=BITAND(-1,1) |
#NUM! |
Negative argument |
=BITAND(1.5,1) |
#NUM! |
Fractional argument |
=BITAND(281474976710656,1) |
#NUM! |
One above the maximum |
=BITAND("bad",1) |
#VALUE! |
Nonnumeric argument |
These error categories are explicitly documented by WPS. In particular, the lesson specifies rejection of fractions, rather than truncation. Changing a cell’s displayed decimal places does not make its stored fractional value an integer.
Troubleshooting and portability
Keep imported flag values as exact integers and validate them before applying the operation. The bounded domain has 48 bit positions; do not assume that negative values use the same signed representation as BIN2DEC, or that a programming language’s arbitrary-width integer rules apply.
The cited lesson does not resolve blank-cell treatment, logical-value coercion, numeric text, array arguments, omitted arguments or error precedence when both inputs are invalid. The examples therefore use explicit numeric scalars and one clearly invalid input at a time. No runtime behavior is inferred for those additional cases.
A decimal output can still be a bit mask. If a report labels the result as an amount or a count, its interpretation will be misleading. Preserve a flag legend and distinguish the raw integer from a human-readable list of enabled options.
Evidence, availability and compatibility
The official WPS Academy BITAND lesson, published 2019-05-23, is the product-specific source for this guide. It was reviewed on October 18, 2026. Its applicability field does not specify an edition, platform or numeric build. General platform links in the website footer do not establish applicability. The publication date establishes that the function was documented by that date; the first release and last supported version remain unknown. The cited lesson does not identify the function as deprecated or retired.
The examples are original, independently calculated expectations based on that documented contract. They were not executed in WPS, and no application screenshot is presented. Before exchanging a workbook, check the formula in the intended WPS edition and locale. These examples use the lesson’s English function names and comma separators; localized entry and file-format round trips have not been tested.