NumberFormat nf = NumberFormat.getInstance(); for (double x = Math.PI; x < 100000; x *= 10) { String formattedNumber = nf.format(x); System.out.println(formattedNumber + "\t" + x); }