Formualizer Docs

BITAND

Returns the bitwise AND of two non-negative integers.

Combines matching bits from both inputs and keeps only bits set in both numbers.

The Formualizer engine in this repository at 0.15.0 plus unreleased changes computes the example results. Known differences from Excel are listed on this page.

Syntax

=BITAND(number1, number2)

Arguments

ArgumentTypeRequiredDefault
number1numberRequired—
number2numberRequired—

Remarks

  • Arguments are coerced to numbers and must be whole numbers in the range [0, 2^48).
  • Propagates input errors.

Error cases

  • Returns #NUM! for negative values, fractional values, or values outside the supported range.

Examples

Combine two integers whose binary representations partly overlap.

Formula =BITAND(12,10)

Expected result 8

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Compare the result when both operands have identical bits.

Formula =BITAND(12,12)

Expected result 12

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Apply the bit operation to two zero operands.

Formula =BITAND(0,0)

Expected result 0

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Negative operands are outside the supported integer domain.

Formula =BITAND(-1,10)

Expected result #NUM!

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Mask selected bits

Formula =BITAND(13,10)

Expected result 8

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

Check least-significant bit

Formula =BITAND(7,1)

Expected result 1

Try this formula

This editor runs the published Formualizer 0.14.0 package, so the last digits can differ and functions newer than that release return #NAME?.

FAQ

When does BITAND return #NUM!?

Inputs must be whole numbers in [0, 2^48); negatives, fractions, and out-of-range values return #NUM!.

Implementation

Engine source

On this page