round down to 1dp js code example
Example 1: round down the number javascript
+3.5 => +3.0
-3.5 => -4.0
+3.5 => +3.0 using Math.floor()
-3.5 => -3.0 using Math.ceil()
Example 2: javascript round .5 down
//standard round function, except round .5 down instead of up
function roundHalfDown(num) {
return -Math.round(-num);
}
roundHalfDown(1.5);// 1
roundHalfDown(1.6);// 2