Here you can find the source of roundUpDown(int number, int by)
public static int roundUpDown(int number, int by)
//package com.java2s; //License from project: Open Source License public class Main { public static int roundUpDown(int number, int by) { int result = number; if (by > 0) { result = number + (by - number % by); } else if (by < 0) { if (number % by == 0) { number--;/*from w ww.j a v a 2 s .c o m*/ result = number - number % by; } else { result = number - number % by; } } else { return result; } return result; } }