BitNot
Interpret the content of register P1 as an integer.
An example
1 of the 178 statements we compiled against the sample database use BitNot. This is the one with the shortest program; the rows that use BitNot are highlighted.
SELECT id & 1, id | 2, id << 3, id >> 1, ~id FROM tracks
| addr | opcode | p1 | p2 | p3 | p4 | p5 |
|---|---|---|---|---|---|---|
| 0 | Init | 0 | 16 | 0 | 0 | |
| 1 | OpenRead | 1 | 19 | 0 | k(2,,) | 0 |
| 2 | Rewind | 1 | 15 | 1 | 0 | 0 |
| 3 | IdxRowid | 1 | 6 | 0 | 0 | |
| 4 | BitAnd | 7 | 6 | 1 | 0 | |
| 5 | IdxRowid | 1 | 6 | 0 | 0 | |
| 6 | BitOr | 8 | 6 | 2 | 0 | |
| 7 | IdxRowid | 1 | 6 | 0 | 0 | |
| 8 | ShiftLeft | 9 | 6 | 3 | 0 | |
| 9 | IdxRowid | 1 | 6 | 0 | 0 | |
| 10 | ShiftRight | 7 | 6 | 4 | 0 | |
| 11 | IdxRowid | 1 | 6 | 0 | 0 | |
| 12 | BitNot | 6 | 5 | 0 | 0 | |
| 13 | ResultRow | 1 | 5 | 0 | 0 | |
| 14 | Next | 1 | 3 | 0 | 1 | |
| 15 | Halt | 0 | 0 | 0 | 0 | |
| 16 | Transaction | 0 | 0 | 1 | 0 | 1 |
| 17 | Integer | 1 | 7 | 0 | 0 | |
| 18 | Integer | 2 | 8 | 0 | 0 | |
| 19 | Integer | 3 | 9 | 0 | 0 | |
| 20 | Goto | 0 | 1 | 0 | 0 |
Open it in the EXPLAIN visualizer →
Also in this program: BitAnd, BitOr, Goto, Halt, IdxRowid, Init, Integer, Next, OpenRead, ResultRow, Rewind, ShiftLeft, ShiftRight, Transaction.
What the SQLite documentation says
Interpret the content of register P1 as an integer. Store the ones-complement of the P1 value into register P2. If P1 holds a NULL then store a NULL in P2.
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.