Beispiel #1
0
        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);
        }
Beispiel #2
0
        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));
            }
        }
Beispiel #3
0
 public static string FormatInt(int value, IntFormat ifm) => ifm switch
 {
Beispiel #4
0
 public BetterStringBuilder Append(int value, IntFormat format = IntFormat.Plain)
 {
     return(this.Append((long)value, format));
 }
Beispiel #5
0
 public ID(int v, IntFormat sf)
 {
     Value  = v;
     Format = sf;
     Active = false;
 }
Beispiel #6
0
 public string ToString(IntFormat format) => $"{HolderType.Name}_{FormatInt(Value, format)}";