Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Write Floating-Point Literals with an exponent

Write the number as a decimal value followed by an E, or an e. Floating-point literals are of type double by default. To specify a value of type float, you append an f, or an F. public class MainClass{   public static void main(String[] arg){      double f1 = 1.496E8;      double f2 = 9.0E-28;          System.out.println(f1);      System.out.println(f2);      System.out.println(f2 + f1);   } } 1.496E8 9.0E-28 1.496E8