I\'m looking for a method that can round a number up to the nearest multiple of another. This is similar Quantization.
Eg. If I want to round 81 up to the
public static int RoundUp(int num, int multiple) { if (multiple == 0) return 0; int add = multiple / Math.Abs(multiple); return ((num + multiple - add) / multiple)*multiple; } static void Main() { Console.WriteLine(RoundUp(5, -2)); Console.WriteLine(RoundUp(5, 2)); } /* Output * 4 * 6 */