public static string ToFixedLengthString(this Rational r, int len, StringBuilder sb) { sb.Length = 0; r.AppendDecimalString(sb, len); if (sb.Length < len) { // Zero-fill remainder. sb.Append('0', len - sb.Length); } return(sb.ToString()); }