0
Java number of decimals
Hello! If I have a double: double number = 35.2; And I need to convert it to 35.20 then how do I do that?
3 Respuestas
+ 1
double d = 35.2;
System.out.printf("%.2f",d);
0
I don't need to just print it but to change its value so that it remains 'number' variable it already is
0
Michał Cukrowski any reason why you want to change it to 35.20? Cuz 35.2 is the exact same thing as 35.20. so there's no need to change it, unless you want to print it in 35.20 format then do what Avinesh said.