private string GetDecimalValue(int precision, int scale, int zerosInPrecision, int zerosInScale) { ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(precision, 1, "precision"); ArgumentValidator.EnsureArgumentIsLessThanOrEqual(precision, 38, "precision"); ArgumentValidator.EnsureArgumentIsGreaterThanOrEqual(scale, 0, "scale"); ArgumentValidator.EnsureArgumentIsLessThanOrEqual(scale, precision - 1, "scale"); ArgumentValidator.EnsureArgumentIsLessThanOrEqual(zerosInPrecision, precision - scale, "zerosInPrecision"); ArgumentValidator.EnsureArgumentIsLessThanOrEqual(zerosInScale, scale, "zerosInScale"); if (zerosInScale > scale) { throw new ArgumentException("", "zerosInScale"); } var meaningfulfloor = string.Join("", Enumerable.Repeat('1', scale - zerosInScale)); var irrelevantFloor = string.Join("", Enumerable.Repeat('0', zerosInScale)); var floor = meaningfulfloor + irrelevantFloor; var ceiling = string.Join("", Enumerable.Repeat('1', precision - scale - zerosInPrecision)); return(floor.Length + zerosInPrecision + ceiling.Length != precision ? throw new Exception("Precision and scale mismatch") : ceiling + "." + floor); }