如何将double
格式化为2个小数点? Decimalformat
或string.format
没有给出预期输出:Android双精度十进制格式
DecimalFormat precision = new DecimalFormat("0.00");
s = mylist.get(0).getHARUALTAESGE();
double hramount = Double.parseDouble(s);
String rb = rebatespin.getSelectedItem().toString();
//below one
double rebamount = (Double.parseDouble(s) * Double.parseDouble(rb.replace("%", "")));
rebateamount.setText(precision.format(rebamount));
double hualr=(hramount-rebamount);
//below other one
haulageprice.setText(String.format("%.2f", hualr));
你看到什么?输出 –
我看到超过两位小数 – neutr0n
请稍后在几秒后显示更多代码 –