Documentation/Calc Functions/BITAND

From The Document Foundation Wiki
Jump to navigation Jump to search
Other languages:
English • ‎dansk • ‎עברית



Function name:

BITAND

Category:

Mathematical

Summary:

Performs a bitwise AND binary operation on two non-negative integer values.

Syntax:

BITAND(Number1; Number2)

Returns:

Returns an integer in the range [0, 248-1], which is the result of the bitwise AND operation on the two supplied numbers.

Arguments:

Number1 is an integer in the range [0, 248-1], or a reference to a cell containing that number, that is the first value for the bitwise AND operation.

Number2 is an integer in the range [0, 248-1], or a reference to a cell containing that number, that is the second value for the bitwise AND operation.

  • If either Number1 or Number2 is non-numeric, then BITAND reports a #VALUE! error.
  • If either Number1 or Number2 is a non-integer value, then BITAND truncates that value to an integer.
  • If either Number1 or Number2 is less than 0 or greater than 248-1, then BITAND reports an invalid argument error (Err:502).

Additional details:

  • 248 is equal to 281474976710656.

Examples:

Formula Description Returns
=BITAND(6; 10) 6 is binary 0110 and 10 is binary 1010. The function evaluates 0110 AND 1010 and returns decimal 2 (binary 0010). 2
=BITAND(D1; D2) where cells D1 and D2 contain the numbers 123 and 156 respectively. 123 is binary 01111011 and 156 is binary 10011100. The function evaluates 01111011 AND 10011100 and returns decimal 24 (binary 00011000). 24
=BITAND(6.123; 10.9) The floor values of the two arguments are taken, giving 6 (binary 0110) and 10 (binary 1010). The function evaluates 0110 AND 1010 and returns decimal 2 (binary 0010). 2

Related LibreOffice functions:

AND

BITLSHIFT

BITOR

BITRSHIFT

BITXOR

ODF standard:

Section 6.6.2, part 2

Equivalent Excel functions:

BITAND