开发者

Saving and retrieving numeric values from Sqlite3

开发者 https://www.devze.com 2022-12-15 07:36 出处:网络
How to properly save a numeric values into SQLite3. I\'ve used Real type for storing numeric value. For example: when I store 233333.00 is fine. But when i store 23333333.00 it becomes 23333300.00. Wh

How to properly save a numeric values into SQLite3. I've used Real type for storing numeric value. For example: when I store 233333.00 is fine. But when i store 23333333.00 it becomes 23333300.00. Why is it saved as 2.3333开发者_如何转开发333E7 and retrieved as 2.33333e+07. Is there a way to overcome this?


The real type used by SQLite is stored as 8-byte IEEE floating point number and can't store all values exactly. If you want exact vales, use either string of integer.


You are losing precision because your program's variable has single precision and you need double.

Floating point is actually perfectly accurate for integral values that fit in the mantissa.

You get 24 bits fot singles and 53 for double.

This isn't an sqlite issue at all.

0

精彩评论

暂无评论...
验证码 换一张
取 消