Imprimer jusqu'à 2 décimales en java
System.out.printf("%.2f", value);
Vivacious Vendace
System.out.printf("%.2f", value);
import java.text.DecimalFormat;
double round2(double num) {
DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(num));
}
double angle = 20.3034;
DecimalFormat df = new DecimalFormat("#.00");
String angleFormated = df.format(angle);
System.out.println(angleFormated); //output 20.30