View Problem

Format a decimal number

Format the number 7/8 as a decimal with 2 places: 0.88
ExpandDiskEdit
groovy
def result = 7/8
println result.round(new MathContext(2))
ExpandDiskEdit
groovy
def result = 7/8
printf "%.2g", result
DiskEdit
groovy 1.6.4
new Double(7/8).round(2)
ExpandDiskEdit
erlang
Formatted = io_lib:format("~.2f", [7/8]),
ExpandDiskEdit
erlang
io:format("~.2f~n", [7/8]).

Submit a new solution for groovy or erlang
There are 26 other solutions in additional languages (clojure, cpp, csharp, fantom ...)