# Math.round(11.5) 与 Math.round(-11.5)

**URL:** <https://www.isharkfly.com/t/math-round-11-5-math-round-11-5/6437>\
**Category:** 程序语言\
**Created:** [December 25, 2010, 3:14am UTC](https://www.isharkfly.com/t/math-round-11-5-math-round-11-5/6437 "2010-12-25T03:14:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![honeymoose](https://www.isharkfly.com/user_avatar/www.isharkfly.com/honeymoose/32/20796_2.png) [@honeymoose](https://www.isharkfly.com/u/honeymoose)\
**Post date:** [December 25, 2010, 3:14am UTC](https://www.isharkfly.com/t/math-round-11-5-math-round-11-5/6437/1 "2010-12-25T03:14:26Z")

</div>

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。
