SQLite VDBE opcode

Divide

Divide the value in register P1 by the value in register P2 and store the result in register P3 (P3=P2/P1).

An example

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

SELECT ms / 1000, ms % 1000, ms * 2, ms - 1, ms + 1 FROM tracks
addropcodep1p2p3p4p5
0Init01600
1OpenRead04040
2Rewind01500
3Column0360
4Divide7610
5Column0360
6Remainder7620
7Column0360
8Multiply8630
9Column0360
10Subtract9640
11Column0360
12Add9650
13ResultRow1500
14Next0301
15Halt0000
16Transaction00101
17Integer1000700
18Integer2800
19Integer1900
20Goto0100

Open it in the EXPLAIN visualizer →

Also in this program: Add, Column, Goto, Halt, Init, Integer, Multiply, Next, OpenRead, Remainder, ResultRow, Rewind, Subtract, Transaction.

What the SQLite documentation says

Divide the value in register P1 by the value in register P2 and store the result in register P3 (P3=P2/P1). If the value in register P1 is zero, then the result is NULL. 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.

← Destroy · DropIndex →