首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Math中ceil,floor,rint跟round的用法

2012-12-21 
Math中ceil,floor,rint和round的用法//Math中ceil,floor,rint和round的用法。public class Test {?public s

Math中ceil,floor,rint和round的用法

//Math中ceil,floor,rint和round的用法。
public class Test {
?public static? void main(String[] args){
//??要是正数就去掉小数点加1,要是负数就去点小数。
??System.out.println(Math.ceil(15.1));
//??要是正数就去掉小数,要是负数就去掉小数减1
??System.out.println(Math.floor(-8.001));
//??返回最接近参数并等于某一整数的 double 值,5为分界点。
??System.out.println(Math.rint(27.9));
//??round和rint的用法,有点相同。
??System.out.println(Math.round(27.9));
?}
}

热点排行