Math.round()对负数操作问题

Math.round()对负数操作问题
System.out.println(Math.round(-11.5));为什么得的是-11
而System.out.println(Math.round(-11.51));得的就是-12呢?
数学人气:654 ℃时间:2020-06-02 19:37:34
优质解答
roundpublic static long round(double a)返回最接近参数的 long.结果将舍入为整数:加上 1/2,对结果调用 floor 并将所得结果强制转换为 long 类型.换句话说,结果等于以下表达式的值:(long)Math.floor(a + 0.5d)特...
我来回答
类似推荐
请使用1024x768 IE6.0或更高版本浏览器浏览本站点,以保证最佳阅读效果。本页提供作业小助手,一起搜作业以及作业好帮手最新版!
版权所有 CopyRight © 2012-2024 作业小助手 All Rights Reserved. 手机版