Reputation: 1335
Lets 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.
Upvotes: 10
Views: 22222
Reputation: 791
Use Math.trunc(7.814);
Do not use Math.floor or similar since they round the number instead of just removing the digits after the comma/dot. I do not know how this has been back in the day but because of this the accepted answer is false nowadays.
Upvotes: 0
Reputation: 16952
Use Math.floor(0.6)
, or if you really want to use string manipulation, String(0.6).split('.')[0]
.
Upvotes: 19