math.round(Math.round函数「建议收藏」)

发布时间:2025-12-10 20:01:02 浏览次数:2

Math.round函数「建议收藏」-math.round(11.5和math.(-11.5))

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开发工具频繁失效而烦恼,来吧关注以下公众号获取最新激活方式。亲测可用!

为防止网络爬虫,请关注公众号回复”口令”

激活idea 激活CLion DataGrip DataSpell dotCover dotMemory dotTrace GoLand PhpStorm PyCharm ReSharper ReShaC++ Rider RubyMine WebStorm 全家桶 刷新

【正版授权,激活自己账号】:Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】:官方授权 正版激活 自己使用,支持Jetbrains家族下所有IDE…

运行结果

如果内容正无限大或者大于等于long的最大值返回Long.MAX_VALUE;

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477