ANDBITS()
This page is part of MariaDB's Documentation.
The parent of this page is: Functions for MariaDB Xpand
Topics on this page:
Overview
Returns a bitwise "and" of two numbers.
USAGE
ANDBITS(number, number)
Argument Name | Description |
---|---|
| Two numbers to combine with bitwise "and" |
DETAILS
ANDBITS()
is a bitwise function that performs a bitwise "and" of two numbers.
If you imagine each number in binary representation aligned by their least-significant bit, a bitwise "and" generates a 1
result bit for each pair of aligned bits that are 1
in both values while generating a 0
result bit for all other bit combinations.
The return value is the number representing the bits that both numbers have in common.
A NULL
is returned if either argument is NULL
.
EXAMPLES
SELECT ANDBITS(5, 4), ANDBITS(1, 3), ANDBITS(0, 7);
+---------------+---------------+---------------+
| ANDBITS(5, 4) | ANDBITS(1, 3) | ANDBITS(0, 7) |
+---------------+---------------+---------------+
| 4 | 1 | 0 |
+---------------+---------------+---------------+