floor取比自己小的整数:
Math.floor(11.4)=Math.floor(11.6)=11;
Math.floor(-11.4)=Math.floor(-11.6)=-12;
ceil取比自己大的整数:
Math.ceil(11.4)=Math.ceil(11.6)=12;
Math.ceil(-11.4)=Math.ceil(-11.6)=-11;
round比较公平(四舍五入):
Math.round(11.6)=Math.round(11.5)=12;
Math.round(-11.6)=Math.round(-11.5)=-12;
Math.round(11.4)=11;
本文详细解析了数学函数floor(向下取整)、ceil(向上取整)和round(四舍五入)的使用方法及特性。通过具体实例展示了不同数值下这些函数的行为,帮助读者理解并掌握其在编程中的应用。
819

被折叠的 条评论
为什么被折叠?



