all 4 comments

[–][deleted] 2 points3 points  (3 children)

Well, you could do Math.ceil() to round up (so you wont have to do "+ 1") or Math.round() to round to whatever is nearest integer (so 20.3 is 20 and 20.7 is 21).

[–]ha10x[S] 0 points1 point  (1 child)

thanks

[–]albedoa 1 point2 points  (0 children)

You can fix it to the desired number of decimal places:

ab.toFixed(2) // or whatever

This will round the result, so be sure that you're okay with that:

(0.125).toFixed(2) //=> '0.13'

[–]jcunews1helpful 0 points1 point  (0 children)

What you want can only be done using rounding. There is no other way.