The March of Progress
Filed in: Web Development — April 6th, 2004C
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..
Comments Feed
TrackBack URL



