BIT_SHIFT_RIGHT

All functions > BITWISE > BIT_SHIFT_RIGHT

Returns the bitstring shifted right by N positions, filling with zeros on the left.

Signatures

Returns: Bitstring shifted right by N positions

BIT_SHIFT_RIGHT(bitstring: BITSTRING, n: BIGINT) → BITSTRING
sql
ParameterTypeRequiredDescription
bitstringBITSTRINGYesBitstring to shift
nBIGINTYesNumber of positions to shift right

Notes

  • Bits shifted beyond the right end are discarded
  • New bits on the left are filled with zeros
  • The length of the result is the same as the input
  • Returns NULL if either input is NULL

Examples

FeatureQL
SELECT
    f1 := BIT_SHIFT_RIGHT('1001011'::BITSTRING, 3)::VARCHAR,  -- Shift right by 3
    f2 := BIT_SHIFT_RIGHT('1000'::BITSTRING, 2)::VARCHAR,  -- Shift right by 2
    f3 := BIT_SHIFT_RIGHT('0001'::BITSTRING, 1)::VARCHAR,  -- Low bit shifted out
    f4 := ('1000'::BITSTRING >> 2)::VARCHAR  -- Operator syntax: >> for shift right
;
Result
f1 VARCHARf2 VARCHARf3 VARCHARf4 VARCHAR
0001001001000000010

Last update at: 2026/03/18 16:18:57
Last updated: 2026-03-18 16:19:34