tencent cloud

Feedback

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
    
    
    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 avaliable.

    7x24 Phone Support