Answers for "kotlin number to k m b"

0

kotlin number to k m b

public String prettyCount(Number number) {
    char[] suffix = {' ', 'k', 'M', 'B', 'T', 'P', 'E'};
    long numValue = number.longValue();
    int value = (int) Math.floor(Math.log10(numValue));
    int base = value / 3;
    if (value >= 3 && base < suffix.length) {
        return new DecimalFormat("#0.0").format(numValue / Math.pow(10, base * 3)) + suffix[base];
    } else {
        return new DecimalFormat("#,##0").format(numValue);
    }
}
Posted by: Guest on September-29-2021

Code answers related to "kotlin number to k m b"

Browse Popular Code Answers by Language