Bitwise right shift

All functions > BITWISE > Bitwise right shift

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

Syntax

expr >> n  ·  BITWISE_SHIFT_RIGHT(expr, n)

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

Related Functions

Examples

BITWISE_SHIFT_RIGHT(...)

FeatureQL
SELECT
    f1 := BITWISE_SHIFT_RIGHT('1001011'::BITSTRING, 3)::VARCHAR, -- Shift right by 3
    f2 := BITWISE_SHIFT_RIGHT('1000'::BITSTRING, 2)::VARCHAR, -- Shift right by 2
    f3 := BITWISE_SHIFT_RIGHT('0001'::BITSTRING, 1)::VARCHAR -- Low bit shifted out
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
000100100100000

Operator >>

FeatureQL
SELECT
    f1 := ('1001011'::BITSTRING >> 3)::VARCHAR, -- Shift right by 3
    f2 := ('1000'::BITSTRING >> 2)::VARCHAR, -- Shift right by 2
    f3 := ('0001'::BITSTRING >> 1)::VARCHAR -- Low bit shifted out
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
000100100100000

Last update at: 2026/05/26 17:22:09