0
How can we give precision to the decimal numbers (float)
4 odpowiedzi
+ 3
System.out.printf("%.xf", number);
Replace x with the number of decimal places you want
+ 1
Use Double instead of float it gives you more precision other than float.
+ 1
If double has not enough precision, use BigDecimal.
This data type isn't primitive. Its an object similar to the wrapper classes (Integer,Character...),
so you need to use methods instead of operators.
It could help to read the documentation
0
float default precision is 6