Android/SQLite : Saving/Retrieving data of type REAL

后端 未结 1 1415
走了就别回头了
走了就别回头了 2020-12-21 09:11

I have a SQLDB with table of field REAL. In my layout I have set its field size to allow only 8+2 digits. In my object I have used the data-type of the field as \"float\".<

相关标签:
1条回答
  • 2020-12-21 09:33

    I think your problem is that you store the numbers as Float. Float does not have very good precision - it actually has only 23 binary digits of precision as seen here. This means that you can not store accurately in float 7 digits before the decimal point or even worse - 7 digits before the point and a couple after. This means that you have incorrectly chosen the type of the balance variable - you can not store in Float 8+2. I would recommend you to change the type to Double, which has significantly larger range of precision.

    0 讨论(0)
提交回复
热议问题