float and double use 32 and 64 bits, respectively.
Float literals end in F or f, double literals end in a digit or D or d.
Floating-point numbers are implicitly doubles (64 bits).
public class MainClass{
public static void main(String[] argv){
double myDouble;
float myFloat;
myDouble = 1.1;
myFloat = 1.2F; // F stands for float
}
}
Ranges of the Floating-Point Primitive Types
Type Size
float 32 bits
double 16 bits
|