当前位置: > Math.round()对负数操作问题...
题目
Math.round()对负数操作问题
System.out.println(Math.round(-11.5));为什么得的是-11
而System.out.println(Math.round(-11.51));得的就是-12呢?

提问时间:2021-03-24

答案
roundpublic static long round(double a)返回最接近参数的 long.结果将舍入为整数:加上 1/2,对结果调用 floor 并将所得结果强制转换为 long 类型.换句话说,结果等于以下表达式的值:(long)Math.floor(a + 0.5d)特...
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
版权所有 CopyRight © 2012-2019 超级试练试题库 All Rights Reserved.