The March of Progress

Filed in: Web Development — April 6th, 2004

 

C
printf("%10.2f", x);

C++
cout < < setw(10) << setprecision(2) << showpoint << x;

Java
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);

Source: http://www.horstmann.com

Read also:

What do you think? View Comments to “The March of Progress”

Comments Feed | TrackBack URL

Comments are closed.

Comments are closed. Submit your comment here