メインコンテンツまでスキップ

>> (gt gt sign) operator

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime 15.4 and above

Returns expr bitwise signed right shifted by n bits. This operator is a synonym for shiftright function.

Syntax​

expr >> n

Arguments​

  • expr: An INTEGER or BIGINT expression.
  • n: An INTEGER expression specifying the number of bits to shift.

Returns​

The result type matches expr.

When expr is negative (that is, the most significant bit is set), the result remains negative because the operator preserves the most significant bit. The effective shift distance is n modulo 32 for an INTEGER expr and modulo 64 for a BIGINT expr.

Examples​

SQL
> SELECT 4 >> 1;
2
> SELECT -4 >> 1;
-2
> SELECT 1 >> -1;
0