+ 2
Float x=3.5f why we need f as suffix?
4 Respostas
+ 4
A 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 can't be saved as a float. 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.
The default value of a float in Java is 0.0f. Float data type is used when you want to save memory and when calculations don't require more than 6 or 7 digits of precision.
Taken from:
https://study.com/academy/lesson/java-floating-point-numbers.html
+ 4
Correct uses:
float fl=4.2f;
float fl= 4.2F;
mistake:
float fl=4.2;
+ 2
Without the F suffix, the compiler will treat them as doubles.
0
Upto which decimal place double can store