转载自 http://blog.csdn.net/com_stu_zhang/article/details/7214565 方法1: float f = 34.232323; BigDecimal b = new BigDecimal(f); float f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); // b.setScale(2, BigDecimal.ROUND
方法1: float f = 34.232323; BigDecimal b = new BigDecimal(f); float f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue(); // b.setScale(2, BigDecimal.ROUND_HALF_UP) 表明四舍五入,保留两位小数 float ft = 134.3435f; int scale = 2