BIT_COUNT()

Overview

Returns the number of bits set in the given argument.

USAGE

BIT_COUNT(number)

Argument Name

Description

number

The number whose bits are counted

DETAILS

BIT_COUNT() is a bitwise function that returns the number of binary bits set in the given number.

The calculation is done with unsigned 64-bit precision.

A NULL is returned if the argument is NULL.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

CREATE TABLE bitcount_example (
  example BIGINT
);
INSERT INTO bitcount_example VALUES
  (42), (101), (99), (13), (64), (86);
SELECT example, BIN(example), BIT_COUNT(example)
  FROM bitcount_example;
+---------+--------------+--------------------+
| example | BIN(example) | BIT_COUNT(example) |
+---------+--------------+--------------------+
|      42 | 101010       |                  3 |
|     101 | 1100101      |                  4 |
|      99 | 1100011      |                  4 |
|      13 | 1101         |                  3 |
|      64 | 1000000      |                  1 |
|      86 | 1010110      |                  4 |
+---------+--------------+--------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES