UnitDisplay.cs 891 B

12345678910111213141516171819202122232425262728293031323334
  1. namespace Plugins.CxShine.Unit
  2. {
  3. public class UnitDisplay
  4. {
  5. public static string KMGTP(long unit)
  6. {
  7. if (unit > 10000000000) return $"{unit / 1000000000.0:N0}G";
  8. if (unit > 10000000) return $"{unit / 1000000.0:N0}M";
  9. if (unit > 10000) return $"{unit / 1000.0:N0}K";
  10. return unit + "";
  11. }
  12. public static long GetMin(long[] numbers)
  13. {
  14. var min = numbers[0];
  15. for (var i = 0; i < numbers.Length; i++)
  16. if (min > numbers[i])
  17. min = numbers[i];
  18. return min;
  19. }
  20. public static long GetMax(long[] numbers)
  21. {
  22. var max = numbers[0];
  23. for (var i = 0; i < numbers.Length; i++)
  24. if (max < numbers[i])
  25. max = numbers[i];
  26. return max;
  27. }
  28. }
  29. }