Beispiel #1
0
 public static string KMGCS(float?number, bool reverseColor = false, KMGType type = KMGType.TenK)
 {
     return(DecorateStr(KMG((int)number, type), number, true, reverseColor));
 }
 public static string KMGCS(this float number, bool reverseColor = false, KMGType type = KMGType.TenK) => BaseUIUtil.KMGCS(number, reverseColor, type);
Beispiel #3
0
        public static string KMG(float?number, KMGType type = KMGType.TenK)
        {
            if (number == null)
            {
                return("");
            }
            float f = GetNumber((int)number);

            return(ValidDigit(f, 2) + GetSuffix((int)number));

            float GetNumber(int num)
            {
                int abs = Mathf.Abs(num);

                if (type == KMGType.TenK)
                {
                    if (abs >= 10000000)
                    {
                        return(num / 1000000);
                    }
                    else if (abs >= 10000)
                    {
                        return(num / 1000.0f);
                    }
                }
                else if (type == KMGType.OneK)
                {
                    if (abs >= 1000000)
                    {
                        return(num / 1000000);
                    }
                    else if (abs >= 1000)
                    {
                        return(num / 1000.0f);
                    }
                }
                return(num);
            }

            string GetSuffix(int num)
            {
                int abs = Mathf.Abs(num);

                if (type == KMGType.TenK)
                {
                    if (abs >= 10000000)
                    {
                        return("M");
                    }
                    else if (abs >= 10000)
                    {
                        return("K");
                    }
                }
                else if (type == KMGType.OneK)
                {
                    if (abs >= 1000000)
                    {
                        return("M");
                    }
                    else if (abs >= 1000)
                    {
                        return("K");
                    }
                }
                return("");
            }
        }
 public static string KMG(this float number, KMGType type        = KMGType.TenK) => BaseUIUtil.KMG(number, type);