A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/getbit below:

Website Navigation


GETBIT | Snowflake Documentation

Categories:

Bitwise expression functions

GETBIT

Given an INTEGER value, returns the value of a bit at a specified position.

Syntax
GETBIT( <integer_expr>, <bit_position> )

Copy

Arguments
integer_expr

This expression must evaluate to a data type that can be cast to an INTEGER value.

bit_position

The position of the bit (starting from 0 for the least significant bit up to 127 for the most significant bit) for which to retrieve the value.

Returns

The function returns the value of the bit (0 or 1) at the specified position.

Examples

The following example returns the values of the bits at positions 100, 3, 2, 1, and 0 for an INTEGER value.

SELECT GETBIT(11, 100), GETBIT(11, 3), GETBIT(11, 2), GETBIT(11, 1), GETBIT(11, 0);

Copy

+-----------------+---------------+---------------+---------------+---------------+
| GETBIT(11, 100) | GETBIT(11, 3) | GETBIT(11, 2) | GETBIT(11, 1) | GETBIT(11, 0) |
|-----------------+---------------+---------------+---------------+---------------|
|               0 |             1 |             0 |             1 |             1 |
+-----------------+---------------+---------------+---------------+---------------+

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4