How to use floating-point literals in Java

1 Answer

0 votes
package javaapplication1;
 
// Literal variables with a fixed value
 
public class Example {
    public static void main(String[] args) 
    {
        double d = 1234.5;
        System.out.println("double: " + d);
     
        double scientificd = 1.2345e3;
        System.out.println("double scientific: " + scientificd);
         
        float f = 1234.5f;
        System.out.println("float: " + f);
    }
}
 
/*
run:
 
double: 1234.5
double scientific: 1234.5
float: 1234.5
 
*/

 



answered Jan 8, 2016 by avibootz

Related questions

1 answer 170 views
1 answer 177 views
1 answer 207 views
207 views asked Jan 8, 2016 by avibootz
1 answer 214 views
214 views asked Jan 8, 2016 by avibootz
2 answers 232 views
...