> For the complete documentation index, see [llms.txt](https://mariadb.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mariadb.com/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators.md).

# Bit Functions and Operators

{% columns %}
{% column %}
{% content-ref url="/pages/GgAxU9wihYxPA6qzr955" %}
[BIT\_COUNT](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bit_count.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Count the set bits. This function returns the number of bits that are set to 1 in the binary representation of a number.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/dVdJELdYwY8N4a4hu0vs" %}
[\~](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-not.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Invert all bits. This unary operator flips every bit in the operand, changing 1s to 0s and 0s to 1s.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/WYcnJqjTwS39AwStcHVH" %}
[|](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-or.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform bitwise OR. This operator compares bits and returns 1 if at least one of the corresponding bits is 1.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/C19ALtdZpgin7orKR6ul" %}
[^](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise-xor.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform bitwise exclusive OR. This operator returns 1 only if the corresponding bits of the operands are different.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/jrqGnaZEhPBAEcPsmQpm" %}
[&](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/bitwise_and.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Perform bitwise AND. This operator compares bits of two operands and returns 1 only if both corresponding bits are 1.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/0GPDlpTx5u0l5eH4AOkK" %}
[Parentheses](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/parentheses.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Control operator precedence. Parentheses are used to group expressions and enforce the order of evaluation in complex operations.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/tz3EPQrz6XXZJjObFV1h" %}
[<<](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-left.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Shift bits to the left. This operator shifts the binary representation of a number to the left by a specified number of positions, filling with zeros.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/4zZP5otOhSWojVh04yuT" %}
[>>](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/shift-right.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Shift bits to the right. This operator shifts the binary representation of a number to the right by a specified number of positions.
{% endcolumn %}
{% endcolumns %}

{% columns %}
{% column %}
{% content-ref url="/pages/ZGokX5nrgTQI7aKL5gcO" %}
[TRUE FALSE](/docs/server/reference/sql-functions/secondary-functions/bit-functions-and-operators/true-false.md)
{% endcontent-ref %}
{% endcolumn %}

{% column %}
Boolean literal for 1 = TRUE or 0 = FALSE, respectively.
{% endcolumn %}
{% endcolumns %}
