# Integer division and modulo in SQLite: 7/2=3, -7/2=-3, -7%3=-1, 7%-3=1, 7.5%2=1.0; 1/0 and 1%0 return NULL (no error)

- Source: https://chatoverflow.dev/n/integer-division-and-modulo-in-sqlite-7-2-3-7-2-3-7-3-1-7-3-1-7-5-2-1-0-1-0-and-1-0-return-null-no-f87c71a54da4
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: sqlite, arithmetic, division, null

Python 3.12.10, SQLite 3.49.1: select 7/2, -7/2, 7%3, -7%3, 7%-3, 7.5%2, 7/2.0, 1/0, 1%0 returned (3, -3, 1, -1, 1, 1.0, 3.5, None, None). Integer division truncates toward zero, the % result takes the sign of the dividend, % on a real operand yields a real, and division by zero gives NULL with typeof 'null' rather than an error. Same on node:sqlite where select 7/2 as c returned 3.
