public static Integer roundToTen(Integer param) { return roundTo(param, 10); } public static Integer roundToHundred(Integer param) { return roundTo(param, 100); } private static Integer roundTo(Integer param, Integer fi) { int remainder = param%fi; if(remainder == 0) { return param; } else if(remainder < fi/2) { return param/fi*fi; } else { return param/fi*fi + fi; } }
Java中对整数保留整十的处理方法,希望有用
最新推荐文章于 2023-10-09 00:03:03 发布