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);
浙公网安备 33010602011771号