js round float code example
Example 1: js rounding
Math.floor(5.5)
Math.round(5.5)
Math.ceil(5.5)
Math.floor(5.57 * 10) / 10
Example 2: round up number typescript
var n = 4.3;
alert(Math.ceil(n));
Example 3: round to nearest decimal javascript
function round(value, precision) {
var multiplier = Math.pow(10, precision || 0);
return Math.round(value * multiplier) / multiplier;
}
Example 4: round to nearest decimal javascript
round(456.7, 2).toFixed(2)
Example 5: how to use math.round
Math.floor(5.5)
Math.round(5.5)
Math.ceil(5.5)
Math.floor(5.57 * 10) / 10
Example 6: round to nearest decimal javascript
round(12345.6789, -1)
round(12345.6789, -2)