Jump to content

Featured Replies

Posted
comment_105002

The march of progress:

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

aggiungo python:

print '%10.2f' % x

  • Risposte 1
  • Visualizzazioni 805
  • Creata
  • Ultima risposta

Top Posters In This Topic

Crea un account o accedi per commentare