rounding - How to round up a number in Javascript? -
i want use javascript round number. since number currency, want round in these examples (2 decimal points):
- 192.168 => 192.20
- 192.11 => 192.20
- 192.21 => 192.30
- 192.26 => 192.30
- 192.20 => 192.20
how achieve using javascript? built-in javascript function round number based on standard logic (less , more 5 round up).
// precision 10 10ths, 100 100ths, etc. function roundup(num, precision) { return math.ceil(num * precision) / precision } roundup(192.168, 10) //=> 192.2
Comments
Post a Comment