Task

Express a number in decimal as a fixed-length string with leading zeros.



For example, the number   7.125   could be expressed as   00007.125.




using Printf
test = [7.125, [rand()*10^rand(0:4) for i in 1:9]]
 
println("Formatting some numbers with the @sprintf macro (using \"%09.3f\"):")
for i in test
    println(@sprintf "    %09.3f" i)
end
 
using Formatting
println()
println("The same thing using the Formatting package:")
fe = FormatExpr("    {1:09.3f}")
for i in test
    printfmtln(fe, i)
end
 