返回其值最接近参数并且是整数的 double 值。如果两个整数的 double 值都同样接近,那么结果取偶数。特殊情况是:如果参数值是整数,那么结果就是该参数。如果参数是 NaN 或无穷大或正零或负零,那么结果与参数相同。参数:a - double 值。返回:最接近 a 的整数浮点值。以下是java API文档中的内容...
{ public static void main(String[] args){ double drint=Math.rint(-3.2);System.out.println("double类型最接近整数为:"+drint);int i=Math.round(-3.2F);System.out.println("int类型最接近整数为:"+i);double dceil=Math.ceil(-3.2);System.out.println("天花板整数为:"+dceil);...
代码和1L差不多,就不贴了直接给代码了double a = 26365;//这个数字是你的米double b = Math.rint(a/100)/10;//这个结果是你要的千米System.out.println(b+"km");直接除以一千呀,四舍五入的话就先加上0.5再舍去后面不要的就行了...除以1000,保留1位小数可以下个换算软件。其实就是一...
用java的math函数库中的函数:rint(random()*100)
java中的三种取整函数 1.Math.floor floor,英文原意:地板。Math.floor 函数是求一个浮点数的地板,就是 向下 求一个最接近它的整数,它的值肯定会小于或等于这个浮点数。Math.floor(-1.1): -2.0 Math.floor(-1.5): -2.0 Math.floor(-1.6): -2.0 Math.floor(0.1): 0.0 Math....