Nachkommastellen
ID | 30 |
---|---|
Link Reference | Not set |
Link Credits | Not set |
Link Technical Documentation | Not set |
PlCodelang | Java |
PlGroup | Zahlen/Rechnen |
PlItemTitle | Nachkommastellen |
Code | import java.text.*; // mindestens 1 Vorkommastelle, genau 2 Nachkommastellen DecimalFormat f = new DecimalFormat("#0.00"); double d1 = 1234.4843; double d2 = 0.2; System.out.println(f.format(d1)); System.out.println(f.format(d2)); // Ausgabe d1=1234,4843 <--- man beachte das Komma! // Ausgabe d2=0,2 |
Result Example |