Here you can find the source of humanReadableNumber(double n)
public static String humanReadableNumber(double n)
//package com.java2s; public class Main { public static String humanReadableNumber(double n) { if (n >= 1e9) { return String.format("%d billion", (Math.round(n / 1e9))); } else if (n >= 1e6) { return String.format("%d million", (Math.round(n / 1e6))); } else if (n >= 1e3) { return String.format("%d thousand", (Math.round(n / 1e3))); } else if (n >= 1) { return String.format("%d", (Math.round(n))); } else if (n > 0.01) { return String.format("%.2f", (n)); } else { // Cheating. return "0.001"; }/*from w w w. j av a2 s. co m*/ } }