如何在Javascript中舍入一个数字? [英] How can I round down a number in Javascript?
本文介绍了如何在Javascript中舍入一个数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在JavaScript中舍入数字?
How can I round down a number in JavaScript?
math.round()
不起作用因为它将它舍入到最接近的小数。
math.round()
doesn't work because it rounds it to the nearest decimal.
我不确定是否有更好的方法可以做到这一点,除了在保持第一位的小数点分开。必须有......
I'm not sure if there is a better way of doing it other than breaking it apart at the decimal point at keeping the first bit. There must be...
推荐答案
Math.floor()
就是答案。
这篇关于如何在Javascript中舍入一个数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文