xxxxxxxxxx
def custom_round(x, base=0.5):
return base * round(float(x)/base)
# you can replace the base parameter with the nearest rounding you need
xxxxxxxxxx
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