开发者

Javascript remove numbers after the dot

开发者 https://www.devze.com 2023-01-05 10:54 出处:网络
L开发者_如何转开发ets say i have this number: 1.5676556 But i want it to show only 1 (without rounding, lets say i have 0.6, if i use math.round, it will round it to 1)

L开发者_如何转开发ets say i have this number: 1.5676556 But i want it to show only 1 (without rounding, lets say i have 0.6, if i use math.round, it will round it to 1)

tnx in advanced.


Use Math.floor(0.6), or if you really want to use string manipulation, String(0.6).split('.')[0].


Try this:

0.12345678.toFixed(2) // "0.12"


You are looking for Math.floor if the number greater than 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号