Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
7+3 =