SQLite

View Ticket
Login
2016-09-20
22:04 Fixed ticket [1ec41379]: Integer multiple fails to overflow to floating-point plus 5 other changes (artifact: db310877 user: drh)
22:04
Improved implementation of 64-bit signed integer multiply that correctly detects overflow (and promotes to floating-point) in some corner cases. Fix for ticket [1ec41379c9c1e400] (check-in: db3ebd7c user: drh tags: trunk)
20:33 New ticket [1ec41379] Integer multiple fails to overflow to floating-point. (artifact: 6af4ab88 user: drh)

Ticket Hash: 1ec41379c9c1e400e0d0d2c1d8f8731c2cbf92f6
Title: Integer multiple fails to overflow to floating-point
Status: Fixed Type: Code_Defect
Severity: Severe Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2016-09-20 22:04:18
Version Found In:
User Comments:
drh added on 2016-09-20 20:33:39:

If integer arithmetic overflows in SQLite, it is suppose to convert the answer to floating point. But sometimes it returns a large negative number:

SELECT 3037000500*3037000500;

Experiments on SqlFiddle.com show that PostgreSQL, MySQL, and SQL Server all throw integer overflow exceptions for the above. Oracle overflows to floating point.

This problem has been in SQLite since before version 3.5.1 (2007-10-04).

Problem reported on the mailing list by Scott Hess from Google.