如何使用 javascript 从十进制数中获取正常数
How to get normal number from Decimal number with javascript
我需要一种将 0.9
转换为 0
并将 0.1
转换为 0
的方法,在 JavaScript.
喜欢math.round(0.9)
但是math.round
给我1
我想要0
Use Math.floor
, it returns the largest integer less than or equal to a given number.
console.log(Math.floor(0.1));
console.log(Math.floor(0.9));
我需要一种将 0.9
转换为 0
并将 0.1
转换为 0
的方法,在 JavaScript.
喜欢math.round(0.9)
但是math.round
给我1
我想要0
Use
Math.floor
, it returns the largest integer less than or equal to a given number.
console.log(Math.floor(0.1));
console.log(Math.floor(0.9));