Display numbers in scientific notation : Decimal « Data Type « Java Tutorial






import java.text.DecimalFormat;
import java.text.NumberFormat;

public class Main {

  public static void main(String args[]) {
    NumberFormat formatter = new DecimalFormat();

    int maxinteger = Integer.MAX_VALUE;

    formatter = new DecimalFormat("0.######E0");
    System.out.println(formatter.format(maxinteger));

  }
}
//2.147484E9








2.47.Decimal
2.47.1.new DecimalFormat(abc#)
2.47.2.DecimalFormat("00E00")
2.47.3.DecimalFormat("000E00")
2.47.4.DecimalFormat("0000000000E0")
2.47.5.new DecimalFormat("0.######E0")
2.47.6.Use new DecimalFormat("0.#####E0") to format double
2.47.7.new DecimalFormat("000000E0")
2.47.8.Use java.text.DecimalFormat to format integer
2.47.9.Display numbers with leading zeroes
2.47.10.Display a percentage
2.47.11.Display a currency value
2.47.12.Force minimum number of digits to left and right of decimal point
2.47.13.DecimalFormat("00.00E0")
2.47.14.The number of #'s to the left of the decimal point sets the multiple of the exponent.
2.47.15.DecimalFormat("##E0") (exponent must be multiple of 2)
2.47.16.DecimalFormat("###E0") (exponent must be multiple of 3)
2.47.17.Change the decimal separator is set to "."
2.47.18.Round number to fewer decimals
2.47.19.Display numbers with commas
2.47.20.Display numbers in scientific notation