SQLite

View Ticket
Login
Ticket Hash: e8bedb2a184001bb49d6df6bc55ff35b9d300cc8
Title: Incorrect result when subtracting a large integer number from a TEXT value
Status: Fixed Type: Code_Defect
Severity: Minor Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-06-07 22:26:40
Version Found In:
User Comments:
mrigger added on 2019-05-26 09:53:37:

Consider the example below:

SELECT '' - 2851427734582196970; -- actual: -2851427734582196736, expected: -2851427734582196970

I expect the subtraction to only affect the number's sign, since I expect the empty string to be converted to zero. However, the subtraction also changes the result's last two least significant digits, even though the result fits into a 64 bit integer. This is not the case for smaller numbers, or when subtracting the value from 0:

SELECT 0 - 2851427734582196970; -- expected: -2851427734582196970
SELECT '' - 1; -- expected: -1