美文网首页
Math.round(),Math.ceil(),Math.fl

Math.round(),Math.ceil(),Math.fl

作者: 空口言_1d2e | 来源:发表于2019-10-31 20:19 被阅读0次

Math.round()

小数点后第一位>5
正数:Math.round(11.68)=12
负数:Math.round(-11.68)=-12
小数点后第一位<5
正数:Math.round(11.46)=11
负数:Math.round(-11.46)=-11
小数点后第一位=5
正数:Math.round(11.5)=12
负数:Math.round(-11.5)=-11
总结:(小数点后第一位)大于五全部加,等于五正数加,小于五全不加。

Math.ceil()

Math.ceil(11.46)=Math.ceil(11.68)=Math.ceil(11.5)=12
Math.ceil(-11.46)=Math.ceil(-11.68)=Math.ceil(-11.5)=-11

Math.floor()

Math.floor(11.46)=Math.floor(11.68)=Math.floor(11.5)=11
Math.floor(-11.46)=Math.floor(-11.68)=Math.floor(-11.5)=-12

相关文章

网友评论

      本文标题:Math.round(),Math.ceil(),Math.fl

      本文链接:https://www.haomeiwen.com/subject/vnxxbctx.html