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

Like this post? Please share:

Follow @liewcf on Twitter; Join Facebook page; Subscribe to free newsletter for updates like this article..

What do you think? No Responses to “The March of Progress”

Comments Feed | TrackBack URL

Comments are closed.

Comments are closed. Submit your comment here

t