Java tutorial
public class Main { public static void main(String[] args) { System.out.printf("%.2e %n", 123456.789); System.out.printf("%.2f %n", 123456.789); System.out.printf("%.2g %n", 123456.789); System.out.printf("'%8.2e' %n", 123456.789); System.out.printf("'%8.2f' %n", 123456.789); System.out.printf("'%8.2g' %n", 123456.789); System.out.printf("'%10.2e' %n", 123456.789); System.out.printf("'%10.2f' %n", 123456.789); System.out.printf("'%10.2g' %n", 123456.789); System.out.printf("'%-10.2e' %n", 123456.789); System.out.printf("'%-10.2f' %n", 123456.789); System.out.printf("'%-10.2g' %n", 123456.789); System.out.printf("'%010.2e' %n", 123456.789); System.out.printf("'%010.2f' %n", 123456.789); System.out.printf("'%010.2g' %n", 123456.789); } }