BIT_SHIFT_LEFT

All functions > BITWISE > BIT_SHIFT_LEFT

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

Signatures

Returns: Bitstring shifted left by N positions

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

Notes

  • Bits shifted beyond the left end are discarded
  • New bits on the right 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_LEFT('1001011'::BITSTRING, 3)::VARCHAR,  -- Shift left by 3
    f2 := BIT_SHIFT_LEFT('0001'::BITSTRING, 2)::VARCHAR,  -- Shift left by 2
    f3 := BIT_SHIFT_LEFT('1000'::BITSTRING, 1)::VARCHAR  -- High bit shifted out
;
Result
f1 VARCHARf2 VARCHARf3 VARCHAR
101100001000000

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19