作为标题,如果数字为1.01,1.02,1.03,1.04,如何将十进制数舍入为1.00,如果数字为0.05,0.06,0.07,0.08,0.09,则将小数点数舍入为0.10
答案 0 :(得分:0)
您可以尝试以下代码:
private static void roundOff(double num) {
double intPart = (int) num;
double rondededOffNum = intPart+ Math.round((num- intPart)*10)/10.0;
System.out.println(rondededOffNum);
}