发布时间:2025-12-10 20:01:02 浏览次数:2
Math.round()函数「建议收藏」Math.round()可以简单的理解为四舍五入函数,在负数的情况下0.5不进位。Returnstheclosestlong totheargument.Theresultisroundedtoanintegerbyadding1/2,takingtheflooroftheresult,andcastingtheresultto
Math.round()可以简单的理解为四舍五入函数,在负数的情况下0.5不进位。
public class TestDemo {public static void main(String[] args) {long r1=Math.round(11.1);long r2=Math.round(11.5);long r3=Math.round(11.6);long r4=Math.round(-11.1);long r5=Math.round(-11.5);long r6=Math.round(-11.6);System.out.println("11.1->"+r1);System.out.println("11.5->"+r2);System.out.println("11.6->"+r3);System.out.println("-11.1->"+r4);System.out.println("-11.5->"+r5);System.out.println("-11.6->"+r6);}} 是否还在为Ide开发工具频繁失效而烦恼,来吧关注以下公众号获取最新激活方式。亲测可用!
【正版授权,激活自己账号】:Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】:官方授权 正版激活 自己使用,支持Jetbrains家族下所有IDE…
运行结果如果内容正无限大或者大于等于long的最大值,返回Long.MAX_VALUE;