#region 大额数值转换Numdispose(float tempNum_, int digits = 2)
/// <summary>
/// 大额数值转换Numdispose(float tempNum_, int digits = 2)
/// </summary>
/// <param name="tempNum_">被转换的数据对象</param>
/// <param name="digits">保留位数</param>
/// <returns></returns>
public static string Numdispose(float tempNum_, int digits = 2)
{
string num = "";
string[] symbol = { "", "K", "M", "B", "T", "aa", "ab", "ac", "ad" };
float tempNum = tempNum_;
long v = 1000;
int unitIndex = 0;
while (tempNum >= v)
{
unitIndex++;
tempNum /= v;
}
if (unitIndex >= symbol.Length)
{
num = tempNum_.ToString();
}
else
{
tempNum = Round(tempNum, digits);
num = $"{tempNum}{symbol[unitIndex]}";
}
return num;
}
public static float Round(float value, int digits)
{
float multiple = Mathf.Pow(10, digits);
float tempValue = value * multiple + 0.5f;
tempValue = Mathf.FloorToInt(tempValue);
return tempValue / multiple;
}
#endregion
游戏大额数值转换“K“, “M“, “B“, “T“, “aa“, “ab“, “ac“, “ad“
最新推荐文章于 2025-04-30 18:07:56 发布