Javascript remove numbers after the dot
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.
精彩评论