The March of Progress
Verfasst: So Jan 29, 2017 9:53 pm
Ich werde ja gerne dafür kritisiert, dass ich bis heute gerne printf in C++ verwende...
The March of Progress, by Cay Horstmann
1980: C
1988: C++
1996: Java
2004: Java
2008: Scala and Groovy
(Thanks to Will Iverson for the update. He writes: “Note the lack of semi-colon. Improvement!”)
2012: Scala 2.10
gefunden hier: http://www.horstmann.com/
The March of Progress, by Cay Horstmann
1980: C
Code: Alles auswählen
printf("%10.2f", x);
Code: Alles auswählen
cout << setw(10) << setprecision(2) << showpoint << x;
Code: Alles auswählen
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);
Code: Alles auswählen
System.out.printf("%10.2f", x);
Code: Alles auswählen
printf("%10.2f", x)
2012: Scala 2.10
Code: Alles auswählen
println(f"$x%10.2f")
gefunden hier: http://www.horstmann.com/