Java tutorial
public class Main { public static void main(String[] args) { System.out.printf("%.2e %n", Double.NaN); System.out.printf("%.2f %n", Double.POSITIVE_INFINITY); System.out.printf("%.2g %n", Double.NEGATIVE_INFINITY); System.out.printf("%(f %n", Double.POSITIVE_INFINITY); System.out.printf("%(f %n", Double.NEGATIVE_INFINITY); } }