记录一下小知识
保留小数点后一位
DecimalFormat df = new DecimalFormat("#.0");
(0.999999);
同理,保留小数点后两位
DecimalFormat df = new DecimalFormat("#.00");
(0.999999);
同理保留小数点后零位
DecimalFormat df = new DecimalFormat("#");
(0.999999);
转int
int num = (new Double(0.999999)).intValue();
或
int num = (int)0.999999;