Question by
alessio1918m · Apr 19 at 03:27 PM ·
optimizationidle
Optimization for number to idle game notation display function?
This function's purpose is to replace a big number, 1405789042927 for example, with "1.40T", I came up with this code after realising that a huge if statement wouldn't be viable for this, the problem is that it looks kinda expensive and the game started lagging a bit after the latest scripts, this function is in my Utils static class and gets called everytime i need to update a TMP text. What are your thoughts on this?
static string notationAtlas = "K M B T Qa Qi Sx Sp Oc No Dc Ud Dd Td Qad Qid Sxd Spd Od Nd V Uv Dv Tv Qav Qiv Sxv Spv Ov Nv Tt";
static string[] notation = notationAtlas.Split(' ');
public static string IdleGameNumberBigDouble(BigDouble number)
{
if (number < 1000) return BigDouble.Round(number) + "";
for (int i = 1; i < notation.Length + 1; i++)
{
if (number < Mathf.Pow(1000, i+1))
{
return (number / Mathf.Pow(1000, i)).ToString("F2") + notation[i-1];
}
}
return (number / Mathf.Pow(1000, notation.Length + 1)).ToString("F2") + "Max";
}
Comment
Your answer

Follow this Question
Related Questions
Failed to Initialize 3D Graphics? 10 Answers
Dynamic Batching for SpritesRender 2 Answers
Anyway to check if a tree is billboard? Script to know if a tree is billboard? 0 Answers
Huge fps drop 1 Answer
Sprite optimization for animation 0 Answers