我尝试通过 sqlite 计算一些结果。我的查询是 SELECT SUM(value) FROM Transaction
。我注意到奇怪的行为。当结果 < 6 个字符是可以的,当结果 > 6 个字符时 sqlite 舍入结果。例如,如果结果为 12345678,则 sqlite 返回 1.23456e+07。谁能解释一下?
我使用 ormlite 在 android 上使用 sqlite。该值为 BIG_DECIMAL。 Ormlite 将其存储为 VARCHAR。
最佳答案
这不是不正确的结果,而是在 scientific E notation 中格式化的结果.
假设您的代码中的值为 double
,则行为为 documented in Double.toString(double)
.
关于android - Sqlite 求和结果不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24036284/