今天爱分享给大家带来Math.round(11.5)等於多少? Math.round(-11.5)等於多少?【面试题详解】,希望能够帮助到大家。
【参考答案】
Math 类中提供了三个与取整有关的方法:ceil、floor、round,这些方法的作用与它
们的英文名称的含义相对应,例如,ceil 的英文意义是天花板,该方法就表示向上取整,
所以,Math.ceil(11.3)的结果为 12,Math.ceil(-11.3)的结果是-11;floor 的英文意义是
地板,该方法就表示向下取整,所以,Math.floor(11.6)的结果为 11,Math.floor(-11.6)
的结果是-12;最难掌握的是 round 方法,它表示“四舍五入”,算法为 Math.floor(x+0.5),
即 将 原 来 的 数 字 加 上 0.5 后 再 向 下 取 整 , 所 以 , Math.round(11.5)的 结 果 为 12,
Math.round(-11.5)的结果为-11。
原文链接:https://blog.itblood.com/2674.html,转载请注明出处。

![超级英雄逊毙了v2.042 AI版[PC+安卓/6.74G/更新]Superheroes Suck [v2.042 Public] [欧美SLG/汉化/动态]](/wp-content/uploads/replace/2025/08/27/a11e6ebbe3b9560167d76db9d7bf71de.webp)