Rounding 235000 to 235?

Hello everyone, I’m looking for some assistance today with an idea I had, So in my game you have currency which you can view in the inventory. What I would like to achieve is say the player has 235145 Gold, I would like to convert that into say 235k.

Does anyone know a way to round to the first number or first 3 numbers?? and this wouldn’t be to convert the whole number but only while displaying it with GUI.label.


100000 = 100k,
1000000 = 1m,
10000000 = 10m,
1000000000 = 1b,

Any assistance would be appreciated :slight_smile: thank you very much!

Google and Stack Overflow know everything.

In this case it was the top search result on Google for “c# string format million”

Heres a nifty extension method I wrote:

  public static class MathExtensions
      public enum RoundingMode
      public static float Round(float value, int digits = 0, RoundingMode mode = RoundingMode.Nearest)
			float rounder = digits == 0 ? 1 : (float)Math.Pow(10, (float)digits);
				case RoundingMode.Up:
					return  (float) (Math.Ceiling(value/rounder) ) * rounder;
				case RoundingMode.Down:
					return (float) (Math.Floor(value/rounder) ) * rounder;
					return (float) (Math.Round(value/rounder) ) * rounder;