Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 大实数之和是整数而不是实数_Android_Sqlite_Floating Point_Sum - Fatal编程技术网

Android 大实数之和是整数而不是实数

Android 大实数之和是整数而不是实数,android,sqlite,floating-point,sum,Android,Sqlite,Floating Point,Sum,我创建了一个包含一些值的表: db.execSQL("create table table_test (" + "id integer primary key autoincrement," + "money real not null" + ");"); ContentValues cv; cv = new ContentValues(); cv.put("money", "137.38"); db.insert("table

我创建了一个包含一些值的表:

db.execSQL("create table table_test ("
                + "id integer primary key autoincrement," 
                + "money real not null" + ");");

ContentValues cv;
cv = new ContentValues();
cv.put("money", "137.38");
db.insert("table_test", null, cv);

cv = new ContentValues();
cv.put("money", "136975.00");
db.insert("table_test", null, cv);
然后我想得到一笔钱:

cursor = db.query("table_test", new String[] { "total(money) as money" }, null, null, null, null, null);
    if (cursor.moveToFirst()) {
      do {
        String money = cursor.getString(cursor.getColumnIndex("money"));
        Log.d(tag, "money=" + money);
      } while (cursor.moveToNext());
    }
cursor.close();
答案应该是137112.38,但它把它四舍五入到137112,我不明白为什么


如果我不输入大的数字,它可以正常工作,但是对于大的数字,我只得到结果的整数部分。

我觉得这些数字看起来不太大。为什么不使用getDouble而不是getString?当它是double时,为什么
getString()
?为什么
if(cursor.moveToFirst()){do{}while(cursor.moveToNext())