zoukankan      html  css  js  c++  java
  • BigDecimal的使用

      1 创建新对象

      BigDecimal BigDecimal(double d); //不允许使用,精度不能保证
      BigDecimal BigDecimal(String s); //常用,推荐使用
      static BigDecimal valueOf(double d); //常用,推荐使用

      2 方法

     3 格式化

      // 格式化:保留2为小数
      DecimalFormat df = new DecimalFormat("#.##");
      // 四舍五入,默认五舍六入
      df.setRoundingMode(RoundingMode.HALF_UP);

    4 舍入模式

      

          

           

           

     
     
  • 相关阅读:
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
    Android
  • 原文地址:https://www.cnblogs.com/pxzbky/p/14267951.html
Copyright © 2011-2022 走看看