Writing a float to an IOStream in decimal notation


Is there a way to force the decimal notation for floats for printing or writing in a file?


@sprintf can do that:

julia> @sprintf("%.3f", Float64(π))

julia> @sprintf("%.8f", Float64(π))

julia> @sprintf("%.8f", 3e8)


Or, if you want to print to a stream directly, then @printf:

julia> @printf(STDOUT, "%f", π)


I often use @printf to do such printing.


Thanks @rdeits @sunoru, it did the trick.