The important thing in life is to have a great aim , and the determination

          常用鏈接

          統計

          IT技術鏈接

          保險相關

          友情鏈接

          基金知識

          生活相關

          最新評論

          JAVA實現四舍五入的方法

          Java實現四舍五入方法

           

          方法一 : 

          double source = 3.129;

          java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");   // 保留小數點后兩位   

          String aveprice=df.format(source);     

           

          方法二 : 

          double source = 3.129;

          BigDecimal bd = new BigDecimal(source);

          bd.setScale(2,BigDecimal.ROUND_HALF_EVEN).floatValue() ;  // 保留小數點后兩位

          posted on 2008-10-30 15:37 鴻雁 閱讀(406) 評論(0)  編輯  收藏 所屬分類: IT技術相關

          主站蜘蛛池模板: 新昌县| 庆元县| 甘孜县| 安泽县| 吕梁市| 恩施市| 页游| 锦州市| 光山县| 紫阳县| 马关县| 贞丰县| 南部县| 漯河市| 南宁市| 盐边县| 长寿区| 日照市| 偃师市| 枣阳市| 邹城市| 岑巩县| 芜湖市| 桃园市| 广汉市| 富裕县| 西乌| 桂阳县| 新巴尔虎左旗| 仁寿县| 右玉县| 西昌市| 隆化县| 宜良县| 偏关县| 珲春市| 旺苍县| 美姑县| 临澧县| 来宾市| 崇阳县|