0

Why minus negative value with SQLite statement getting incorrect result?

See my query at Chrome browser below:- click for image details

  • The result is correct. Where is the problem? The result you got was as close to zero as you can get with floating point and those numbers. And please don't post screenshot only questions. – Sami Kuhmonen Dec 20 '15 at 05:03
  • Sami Kuhmonen... I don't know it work this way. Difference with Math. :) – Kang Chian Gim Dec 23 '15 at 08:04

1 Answers1

0

http://floating-point-gui.de/basic/ might be a good read. SQLite does not have a good mechanism to handle decimal datatypes (high decimal precision). In order to get around this, just create your database to take integers. Store 99.50 as 9950. When extracting data, divide by 100.

A question on dba StackExchange was asked some time back. Although the accepted answer is not a recommended solution, it offers an idea of what is going on with floating points.

Community
  • 1
  • 1
zedfoxus
  • 35,121
  • 5
  • 64
  • 63
  • Thanks for fast response. It offers an idea what is going on with above post. At the end i fix this issue with alternative: Perform rounding for end result to fix this issue. – Kang Chian Gim Dec 23 '15 at 04:51