Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

round to nearest step

function round(number, increment, offset) {
    return Math.ceil((number - offset) / increment ) * increment + offset;
}
round(51,  20, 10) // 70
round(70,  20, 10) // 70
round(99,  20, 10) // 110
round(100, 20, 10) // 110
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nearest #step
ADD COMMENT
Topic
Name
8+4 =