using UnityEngine; namespace BingoBrain.Core { public class HRsac { public static string[] UnitSuffixs = { "", "K", "M", "B", "T", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj ", "ak", "al", "am", "an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az", "ba", "bb", "bc", "bd", "be", "bf", "bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv", "bw", "bx", "by", "bz", "ca", "cb", "cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl", "cm", "cn", "co", "cp", "cq", "cr", "cs", "ct", "cu", "cv", "cw", "cx", "cy", "da", "db", "dc", "dd", "de", "df", "dg", "dh", "di", "dj", "dk", "dl", "dm", "dn", "do", "dp", "dq", "dr", "ds", "dt", "du", "dv", "dw", "dx", "dy" }; #region 最新需求 public static int GetDigitNumber(double value) { int count = 0; while (value > 1) { count++; value = value / 10; } return count; } #endregion 最新需求 public static string ConvertUnit(int value) { int unit = GetDigitNumber(value); if (unit > 0) { unit--; } int unitIdx = 0; if (unit >= 6) { unitIdx = (int)Mathf.Ceil(unit / 3) - 1; } unitIdx = Mathf.Min(unitIdx, UnitSuffixs.Length - 1); float baseNum = Mathf.Pow(10, unitIdx * 3); string numToShow = Mathf.Ceil(value / baseNum).ToString(); string numToShowString = string.Empty; int j = 0; for (int i = numToShow.Length - 1; i >= 0; i--) { j++; numToShowString = numToShow[i] + numToShowString; if (i != 0 && j % 3 == 0) { numToShowString = "," + numToShowString; } } return numToShowString + UnitSuffixs[unitIdx]; } } }