Sunday 13 March 2016

The Java Language: Floating-point literals

Floating-point values can be specified in decimal or scientific notation. Floating-point literals are of type double unless they are suffixed with an f or F denoting that they are to be produced as a float value. And just as with integer literals, in Java 7 you may use “_” underscore characters to format floating-point numbers—but only between digits, not at the beginning, end, or next to the decimal point or “F” signifier of the number.

 double d = 8.31;  
 double e = 3.00e+8;  
 float f = 8.31F;  
 float g = 3.00e+8F;  
 float pi = 3.14_159_265_358;  

0 comments:

Post a Comment