微信二维码
微博二维码
qq号二维码

Math.round( )用法

王伟平 2020-09-18 JAVA 106人浏览

Math.round(11.5)等於多少? Math.round(-11.5)等於多少?

Math.round(11.1)等於多少?

7个回答
胡寒

Math.round(11.5)==12.0

Math.round(-11.5)==-11.0

Math.round(11.1)==11.0

本质是加0.5然后向下取整

回答已被采纳   2020-09-18
杨磊

Math.round(11.5)=12

  2020-09-21
杨磊

Math.round(-11.5)=11

  2020-09-21
杨磊

Math.round(11.1)=11

  2020-09-21
杨磊

返回一个最接近的值,如果是0.5最向正无穷方向取值

  2020-09-21
赵瑞

  round方法,他表示“四舍五入”,算法为Math.floor(x+0.5),即将原来的数字加上0.5后再向下取整

  2020-09-24
赵瑞

Math.round(11.5)=12

Math.round(-11.5)=-11

Math.round(11.1)=11

  2020-09-24
分享到: