I want to be able to have very long integers to be converted to a readable string
This goes from 1500 (1.50k) to 12.500.000.000 being 12.50b and so on to unreadable numbers that will be labeled as A then B etc.
Now I'm pretty sure there's a nifty piece of logic that says if the string length of the integer is 9 the dots should be on place 3 and 6 or something.
My math(and its programmable logic) is non-existent for me so can anyone help me out?
This is my messy and non-reusable attempt now:
int val = 150050004;
string theValue = val.ToString();
int valLength = theValue.Length;
string newVal = theValue;
if (valLength == 7) {
newVal = theValue.Substring(0, 1) +"."+ theValue.Substring(1, 2);
}
if (valLength == 8) {
newVal = theValue.Substring(0, 2) +"."+ theValue.Substring(2, 2);
}
if (valLength == 9) {
newVal = theValue.Substring(0, 3) +"."+ theValue.Substring(3, 2);
}
if (valLength > 6 && valLength < 10) {
newVal = newVal + "m";
}
Where newVal outputs 150.05m