BigDumDum
New member
- Joined
- Mar 21, 2020
- Messages
- 2
- Programming Experience
- Beginner
im new to coding and C# and wanted to make an idle game, i implemented a word notation system, which was far more frustrating than i wish it would have been, the result was that 1000 was displayed as 1K, which i wanted. but 1501 was displayed as 2K, rounded up, so i had to add two decimals preventing it from doing that, which is fine i prefer it with decimals anyway now that i think about it. but it also gives number below 1000 decimals, example 398.85 instead of 398, and i have no idea how to fix that, any help is highly appreciated
here is the code for the WordNotation iself
and heres the values the WordNotation is applied to
here is the code for the WordNotation iself
C#:
public string WordNotation(double number, string digits)
{
double digitsTemp = Math.Floor(Math.Log10(number));
IDictionary<double, string> prefixes = new Dictionary<double, string>()
{
{3, "K"},
{6, "M"},
{9, "B"},
{12, "T"},
{15, "q"},
{18, "Q"},
{21, "s"},
{24, "S"},
{27, "O"},
{30, "N"},
{33, "D"},
{36, "U"},
{39, "Du"},
{42, "Tr"},
{45, "Qa"},
{48, "Qi"},
{51, "Sex"},
{54, "Sep"},
{57, "Oc"},
{60, "No"},
{63, "V"}
};
double digitsEvery3 = 3 * Math.Floor(digitsTemp / 3);
if (number >= 1000)
return (number / Math.Pow(10, digitsEvery3)).ToString(digits) + prefixes[digitsEvery3];
return number.ToString(digits);
}
and heres the values the WordNotation is applied to
C#:
SoulsClickValueText.text = "Tap\n+" + WordNotation(SoulsClickValue, "F2") + " Souls";
SoulsText.text = " " + WordNotation(souls, "F2");
Last edited by a moderator: