View Problem

Format a decimal number

Format the number 7/8 as a decimal with 2 places: 0.88
ExpandDiskEdit
scala
val formatted = String.format("%3.2f", double2Double(7./8.))
ExpandDiskEdit
scala
printf("%3.2f\n", 7./8.)
ExpandDiskEdit
java 1.5 or later
String formatted = String.format("%3.2f", 7./8.);

Submit a new solution for scala or java
There are 28 other solutions in additional languages (clojure, cpp, csharp, erlang ...)