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: (text/x-fossil-wiki)
Consider the example below:

<pre>
SELECT '' - 2851427734582196970; -- actual: -28514277345821967<b>36</b>, expected: -28514277345821969<b>70</b>
</pre>

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:

<pre>
SELECT 0 - 2851427734582196970; -- expected: -2851427734582196970
SELECT '' - 1; -- expected: -1
</pre>