tencent cloud

All product documents
Data Lake Compute
Bitwise Functions
Last updated: 2024-08-07 17:31:33
Bitwise Functions
Last updated: 2024-08-07 17:31:33

BIT_COUNT

Function statement:
BIT_COUNT(<expr> bigint|boolean)
Supported engines: SparkSQL and Presto
Usage instructions: Set expr to an unsigned 64-bit integer and return the number of bits that are 1. If the parameter is NULL, NULL is returned.
Return type: integer
Example:
> SELECT bit_count(5);
2

BIT_GET

Function statement:
BIT_GET(<expr> bigint|boolean, <pos> integer)
Supported engines: SparkSQL and Presto
Usage instructions: Return the value of the bit at the specified position (0 or 1). Positions are numbered from right to left, starting at zero. The position parameter cannot be negative.
Return type: integer
Example:
> SELECT bit_get(11, 0);
1
> SELECT bit_get(11, 2);
0

GETBIT

Function statement:
GETBIT(<expr> bigint|boolean, <pos> integer)
Supported engines: SparkSQL and Presto
Usage instructions: Return the value of the bit at the specified position (0 or 1). Positions are numbered from right to left, starting at zero. The position parameter cannot be negative.
Return type: integer
Example:
> SELECT getbit(11, 0);
1
> SELECT getbit(11, 2);
0


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon