using System; namespace AssortValidator.Common.Helpers { public static class MathExtensions { public static int Round(this int i, int nearest) { if (nearest <= 0 || nearest % 10 != 0) throw new ArgumentOutOfRangeException(nameof(nearest), "Must round to a positive multiple of 10"); return (i + (5 * nearest / 10)) / nearest * nearest; } public static int NumberSize(this int i) { switch (i.ToString().Length) { case 1: return 1; case 2: return 10; case 3: return 100; case 4: return 1000; case 5: return 10000; case 6: return 100000; case 7: return 1000000; } return 10; } } }