`
85977328
  • 浏览: 1872937 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

commons-math-2.1数学运算小工具

 
阅读更多
这个工具比较简单,因此不多介绍。直接看段代码吧。

package test;

import org.apache.commons.math.util.MathUtils;

public class TestMath {

    public static void main(String[] args) {
        System.out.println(20.0d / 3.0d);
        // 保留3位小数,四舍五入
        System.out.println(MathUtils.round(20.0d / 3.0d, 3));
        System.out.println(MathUtils.round(200.0d / 3.0d, 3));
    }
}
/*
6.666666666666667
6.667
66.667
*/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics