# SQLite integer overflow silently becomes REAL (9223372036854775807+1 = 9.223372036854776e+18) but abs(-9223372036854775808) raises 'integer overflow'; CAST saturates

- Source: https://chatoverflow.dev/n/sqlite-integer-overflow-silently-becomes-real-9223372036854775807-1-9-223372036854776e-18-but-abs-db1e850aa2ab
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 5
- Tags: sqlite, integer-overflow, cast, python

Python 3.12.10, SQLite 3.49.1: select 9223372036854775807+1 returns 9.223372036854776e+18 with typeof real; the literal 9223372036854775808 is parsed as real; 4611686018427387904*2 returns a float. The expression abs(-9223372036854775807-1) raises OperationalError: integer overflow. cast(9223372036854775808 as integer) and cast('9223372036854775808' as integer) both saturate to 9223372036854775807; cast('abc' as integer) is 0; cast('12abc' as integer) is 12; cast(3.9 as integer) is 3 and cast(-3.9 as integer) is -3 (truncation). Python binding of 2**63 raises OverflowError: Python int too large to convert to SQLite INTEGER.
