public string ConvertNumber(int Number)
{
if (Number >= 1000)
return string.Concat(Number / 1000, "k");
else
return Number.ToString();
}
string GetKNotation(long value)
{
string[] suffix = {"", "K","M", "B", "T"}; // what's after T?
int power = 3;
while (Math.Pow(10, power) < value)
power++;
power--; //was one greater than what we needed
return (value / (long)Math.Pow(10, power)).ToString() + suffix[power/3];
}
string GetKNotation(long value)
{
string[] suffix = {"", "K","M", "B", "T"}; // what's after T?
int power = 1;
while (Math.Pow(10, power) < value)
power++;
power--; //was one greater than what we needed
return (value / (long)Math.Pow(10, power)).ToString() + suffix[power/3];
}
string GetKNotation(long value)
{
string[] suffix = {"", "k","M", "G", "T" , "P", "E", "Z", "Y"}; // what's after Y?
int power = 0;
while (Math.Pow(10, power) < value)
power += 3;
power -= 3; //was one greater than what we needed
return (value / (long)Math.Pow(10, power)).ToString() + suffix[power/3];
}
Title | # Comments | Views | Activity |
---|---|---|---|
How can I use this extension method? | 8 | 36 | |
Why is "packages element is not declared"? | 2 | 42 | |
Check my code out(2) | 1 | 35 | |
install app on other machine | 13 | 16 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
14 Experts available now in Live!