/**
* 使用这个方法将订单金额在十位四舍五入
* 若:1568.145 装换后:1570
* 1522 转成 1520
*/
import java.math.BigDecimal;

public class myround {
    public static void main(String[] args) {
        myround  m = new myround();
        BigDecimal num = new BigDecimal(1245656.24);
        Double db = num.doubleValue();
        System.out.println(m.roundTen(db));
    }
    private int roundTen(double db) {
        int roundedInt = (int) Math.round(db);

        if (roundedInt % 10 < 5) {
        return (roundedInt / 10) * 10;
        }

        return (roundedInt / 10) * 10 + 10;

        }
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-14
猜你喜欢
  • 2022-12-23
  • 2021-08-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-18
  • 2021-06-02
相关资源
相似解决方案