|Title:||-'1.0' computes -1.0 rather than -1|
|Last Modified:||2019-06-11 13:43:09|
|Version Found In:|
mrigger added on 2019-06-11 09:47:36:
In the example below, I expect the conversion of '1.0' to an INT to yield 1, however, it yields 1.0: <pre> SELECT -'1.0'; -- expected: -1, actual: -1.0 </pre> This is also the case for other floating-point strings whose conversion to INT would be lossless. I expect the conversion to behave as a CAST to NUMERIC, as stated in the documentation: <pre> All mathematical operators (+, -, *, /, %, <<, >>, &, and |) cast both operands to the NUMERIC storage class prior to being carried out. </pre> The conversion works as expected for CASTs: <pre> SELECT -CAST('1.0' AS NUMERIC); -- -1 </pre>
drh added on 2019-06-11 13:43:09: (text/x-fossil-wiki)
Documentation updated to align with the implementation. See [https://www.sqlite.org/docsrc/info/e0f700bb6c8142c5]. Test cases added to TH3.