Math.

Math.floor
floor -- 原意 地板。
数学函数,求一个浮点数的地板,就是求一个最接近它的整数,它的值小于或等于这个浮点数。

例如:
Math.floor(0.60)  -- 0
Math.floor(0.40)  -- 0
Math.floor(5)  -- 5
Math.floor(5.1) -- 5
Math.floor(-5.1) -- -6
Math.floor(-5.9) -- -6

round 取整

 public static int round(float f) {
        // check for NaN
        if (f != f) {
            return 0;
        }
        return (int) floor(f + 0.5f);
    }

abs 绝对值

  public static native int abs(int i);

posted on 2013-03-05 10:20  _star  阅读(158)  评论(0)    收藏  举报

导航