Engineering

BITAND Formula

Returns the bitwise AND of two non-negative integers. Each bit in the result is 1 only if the corresponding bits in both input numbers are 1. BITAND is used in programming logic, flag testing, subnet masking, and any scenario where you need to check if specific bits are set in a value.

Syntax

BITAND(number1, number2)
ParameterDescription
number1 Parameter of the BITAND function.
number2 Parameter of the BITAND function.
Try BITAND in Viztab — free, no signup

Examples

Basic AND operation

Formula
=BITAND(5, 3)
1. In binary: 101 AND 011 = 001, which is 1 in decimal. Only the rightmost bit is set in both numbers.

Test if a flag bit is set

Formula
=BITAND(13, 4)
4. In binary: 1101 AND 0100 = 0100. Bit 2 (value 4) is set in 13, so BITAND returns 4 (non-zero = true).

Subnet mask application

Formula
=BITAND(192, 240)
192. Applying a 240 (11110000) mask to 192 (11000000) yields 192 (11000000) — the upper nibble is preserved.

Common Errors

#NUM!

One or both numbers is negative, or exceeds 2^48 - 1 (281,474,976,710,655).

#VALUE!

An argument is non-numeric.

Tips

Flag checking pattern

To test if flag bit N is set: IF(BITAND(value, 2^N) > 0, "Set", "Not set"). This is standard practice in systems programming.

Both inputs must be non-negative

BITAND doesn't support negative numbers. If you're working with signed values, convert them first.

48-bit limit

Maximum supported value is 2^48-1. This covers most practical use cases but won't handle 64-bit integers directly.

Try BITAND in Viztab

Import your data and use BITAND with 370+ other formulas. No signup required.

Open Viztab

Related Formulas