Format double value in scientific notation in Java
Description
The following code shows how to format double value in scientific notation.
Example
//from w w w .java 2 s. c o m
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));
}
}
The code above generates the following result.
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »