namespace Managing.Core { public static class MathHelpers { public static int GetDecimalPlaces(decimal n) { n = Math.Abs(n); //make sure it is positive. n -= (int)n; //remove the integer part of the number. var decimalPlaces = 0; while (n > 0) { decimalPlaces++; n *= 10; n -= (int)n; } return decimalPlaces; } public static int GetDecimalPlaces(string n) { return n.Split('.')[1].Length - 1; } } }