Dear Phany,
The float data type is a single-precision 32-bit IEEE 754 floating-point. The double data type is a double-precision 64-bit IEEE 754 floating-point.
A float is mainly used to save memory in large arrays of floating-point numbers. Always we need to remember that data type should never be used for precise values, such as currency.
The double data type is normally the default choice for decimal values. The data type should never be used for precise values, such as currency.
Default Values:
Data Type | Default Value (for fields) |
float | 0.0f |
double | 0.0d |
Float data type in Java stores a decimal value with 6-7 total digits of precision. So, for example, 12.12345 can be saved as a float, but 12.123456789 cannot be saved as afloat. When representing a float data type in Java, we should append the letter f to the end of the data type; otherwise, it will save as double.
Double data type stores decimal values with 15-16 digits of precision. The default value is 0.0d; this means that if you do not append for d to the end of the decimal, the value will be stored as a double in Java.
Thanks.