Skip to content

DigitUnit gives the given number a unit (=digiunit) according to the number of digits and returns it. It is a unit such as aa, ab... zz, which is common in management simulation games and tycoon games.

License

Notifications You must be signed in to change notification settings

key-sp/DigitUnit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DigitUnit

DigitUnit gives the given number a unit (=digiunit) according to the number of digits and returns it. It is a unit such as aa, ab... zz, which is common in management simulation games and tycoon games.

Numbers up to 2198 digits can be represented using this digitunit using BigInteger There is also an overload using double , but it can only represent a smaller number of digits.

DigitUnit

The list of digitunit is generated with the code below.

  public static string GetDigitUnit(int numberOfDigits)
  {
      if (DigitUnit.digitSymbolList == null)
      {
          string digitSymbol = " kmbt";
          string atoz = " abcdefghijklmnopqrstuvwxyz";
          var atozList = atoz.SelectMany(y1 => atoz.Select(y2 => (y1, y2)))
              .Select(x => x.y1.ToString() + x.y2.ToString())
              .Select(x => x.Replace(" ", ""))
              .Where(x => x != "")
              .ToList();
          var digitSymbolList = digitSymbol.Select(x => x.ToString()).ToList();
          digitSymbolList.AddRange(atozList);
          DigitUnit.digitSymbolList = digitSymbolList;
      }
      if (numberOfDigits >= digitSymbolList.Count)
          return "";

      return digitSymbolList[numberOfDigits];
  }

If the number of digits is 2199 or more, it will be displayed as "∞" as shown in the image below.

DigitUnit2

About

DigitUnit gives the given number a unit (=digiunit) according to the number of digits and returns it. It is a unit such as aa, ab... zz, which is common in management simulation games and tycoon games.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages