Programming evolition


1980: C

  1. printf("%10.2f", x);

1988: C++

  1. cout < < setw(10) << setprecision(2) << showpoint << x;

1996: Java

  1. java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
  2. formatter.setMinimumFractionDigits(2);
  3. formatter.setMaximumFractionDigits(2);
  4. String s = formatter.format(x);
  5. for (int i = s.length(); i &lt; 10; i++)
  6.     System.out.print(' ');
  7. System.out.print(s);

2004: Java

  1. System.out.printf("%10.2f", x);

Information and Links

Join the fray by commenting, tracking what others have to say, or linking to it from your blog.


Other Posts






Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!