-1
我收到數字格式異常錯誤..要比較存儲在數據庫中的值作爲字符串值。下面代碼中「百分比」的值將是+ 10.05%或-10.05%,「 percentabove」值會像11.05和‘percentbelow’值是10.00 ..數字格式異常錯誤
代碼:
percentabove = cursor.getString(cursor.getColumnIndex(DBConstants.PERCENTABOVE));
percentbelow = cursor.getString(cursor.getColumnIndex(DBConstants.PERCENTBELOW));
}while(cursor.moveToNext());
double newprice= Double.parseDouble(percent);
double maxprice = Double.parseDouble(percentabove);
double minprice = Double.parseDouble(percentbelow);
if(newprice>maxprice || newprice<minprice)
{
String status="";
if(newprice>maxprice)
{
status="Up";
}
else if(newprice<minprice)
{
status="Down";
}
有format..Can我們使用的DecimalFormat任何建議更改格式雙到其他數據類型?
你檢查你有什麼與此? double newprice = Double.parseDouble(percent); – 2013-03-02 08:08:53
請編輯你的問題與你正在綁定解析的字符串的真實例子。 – Simon 2013-03-02 08:32:35