js几个取整函数
Math.floor() Math对象的方法--取比当前数值小的最大整数(下取整)。
Math.ceil() Math对象的方法--取比当前数值大的最小整数(上取整)。
Math.round() Math对象的方法--四舍五入。
toFixed() Number对象的方法--四舍五入保留n位小数。
返回 NumberObject 的字符串表示。
script type="text/javascript"> document.write(Math.round(-7.6)); //-8 document.write(Math.ceil(-7.6)); //-7 document.write(Math.floor(-7.6)); //-8 var a = 12.3456 document.write(a.toFixed(2)); //12.35 </script>
知我罪我,其惟春秋!