SQLite

View Ticket
Login
Ticket Hash: 412bba9b22c677daf4d3128a41b5ecc2a9e46323
Title: CAST('.' AS NUMERIC) computes 0.0 rather than 0
Status: Fixed Type: Code_Defect
Severity: Minor Priority: Immediate
Subsystem: Unknown Resolution: Fixed
Last Modified: 2019-06-10 23:45:20
Version Found In:
User Comments:
mrigger added on 2019-06-10 19:53:54:

Consider the following statement:

SELECT -'.'; -- expected: 0, actual: 0.0

It seems that the '.' is confused with a floating-point number when used with the unary minus. This is also the case for other arithmetic operators (e.g., see below).

SELECT '.' + 0; -- expected: 0, actual: 0.0

This is unexpected, since according to https://www.sqlite.org/syntax/numeric-literal.html, the '.' should be followed by at least one digit to be a valid number.

Previously, this worked as expected and still works as expected when casting '.' to NUMERIC:

SELECT -CAST('.' AS NUMERIC); -- 0

See [4c2d7639f0], where CAST('-' AS NUMERIC) previously computed 0.0.