How to convert/format numbers? (eg. 123K, 456M, 789B)

a simple way to format numbers?

1000 - 1K
1000000 - 10M

you get it, sorry this is so little but im a little annoyed since i just wrote a paragraph and a half but when attempting to post it erased it all…

can someone help me out with this and perhaps explain what it all means
my knowledge of C# next to useless

The following code should do what you want. You can easily add additional abbrevations.

using UnityEngine;
using System.Collections.Generic;
using System.Linq;

public class Test : MonoBehaviour
    void Start()
        //Some tests
        Debug.Log("123000 is "+ AbbrevationUtility.AbbreviateNumber(123000));
        Debug.Log("456000000 is " + AbbrevationUtility.AbbreviateNumber(456000000));
        Debug.Log("789000000000 is " + AbbrevationUtility.AbbreviateNumber(789000000000));
        Debug.Log("1000 is " + AbbrevationUtility.AbbreviateNumber(1000));
        Debug.Log("1000000 is " + AbbrevationUtility.AbbreviateNumber(1000000));

public static class AbbrevationUtility
    private static readonly SortedDictionary<int, string> abbrevations = new SortedDictionary<int, string>
        {1000000, "M" },
        {1000000000, "B" }

    public static string AbbreviateNumber(float number)
        for (int i = abbrevations.Count - 1; i >= 0; i--)
            KeyValuePair<int, string> pair = abbrevations.ElementAt(i);
            if (Mathf.Abs(number) >= pair.Key)
                int roundedNumber = Mathf.FloorToInt(number / pair.Key);
                return roundedNumber.ToString() + pair.Value;
        return number.ToString();

I just made a quick new project to test this out, made a format script with your code in it and an “add” script which adds 50 to the 3d text as a score, i got no clue how to set this up or anything, half of it ive never seen, i try looking for videos that explain this but most my knowledge is from 1 of AwfulMedia’s playlist :frowning:

How about 12.5K or 987.5M ??