public static string IntToString(int value, char[] baseChars, IntFormat fm) { // 32 is the worst cast buffer size for base 2 and int.MaxValue int i = 32; char[] buffer = new char[i]; int targetBase = baseChars.Length; do { buffer[--i] = baseChars[value % targetBase]; value /= targetBase; }while (value > 0); char[] result = new char[32 - i]; Array.Copy(buffer, i, result, 0, 32 - i); string newstring = new string(result); for (int b = Digits[(int)fm] - newstring.Length; b > 0; b--) { newstring += "0"; } return(newstring); }
public BetterStringBuilder Append(long value, IntFormat format = IntFormat.Plain) { switch (format) { case IntFormat.Plain: return(this.AppendLong(value, false)); case IntFormat.ThousandsSeperated: return(this.AppendLong(value, true)); case IntFormat.Abbreviated: return(this.AppendAbbreviated(value)); default: Debug.LogErrorFormat("Found Unknown IntFormat {0}", format); return(this.AppendLong(value, false)); } }
public static string FormatInt(int value, IntFormat ifm) => ifm switch {
public BetterStringBuilder Append(int value, IntFormat format = IntFormat.Plain) { return(this.Append((long)value, format)); }
public ID(int v, IntFormat sf) { Value = v; Format = sf; Active = false; }
public string ToString(IntFormat format) => $"{HolderType.Name}_{FormatInt(Value, format)}";