SQLite VDBE opcode

ShiftRight

Shift the integer value in register P2 to the right by the number of bits specified by the integer in register P1.

An example

1 of the 178 statements we compiled against the sample database use ShiftRight. This is the one with the shortest program; the rows that use ShiftRight are highlighted.

SELECT id & 1, id | 2, id << 3, id >> 1, ~id FROM tracks
addropcodep1p2p3p4p5
0Init01600
1OpenRead1190k(2,,)0
2Rewind115100
3IdxRowid1600
4BitAnd7610
5IdxRowid1600
6BitOr8620
7IdxRowid1600
8ShiftLeft9630
9IdxRowid1600
10ShiftRight7640
11IdxRowid1600
12BitNot6500
13ResultRow1500
14Next1301
15Halt0000
16Transaction00101
17Integer1700
18Integer2800
19Integer3900
20Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: BitAnd, BitNot, BitOr, Goto, Halt, IdxRowid, Init, Integer, Next, OpenRead, ResultRow, Rewind, ShiftLeft, Transaction.

What the SQLite documentation says

Shift the integer value in register P2 to the right by the number of bits specified by the integer in register P1. Store the result in register P3. If either input is NULL, the result is NULL.

From sqlite.org's list of opcodes for SQLite 3.54.1, in the public domain. Opcodes are not a stable interface and change between releases.

← ShiftLeft · SoftNull →