Formatting.jl
Formatting.jl copied to clipboard
Returns dramatically wrong results
julia> using Formatting
julia> Formatting.fmt(".1e", 0.0003)
"2.10e-04"
For comparison, the Printf stdlib returns the correct result:
julia> using Printf
julia> @sprintf "%.1e" 0.0003
"3.0e-04"
Another example:
julia> using Formatting
julia> Formatting.fmt(".1e", 0.0006)
"5.10e-04"
~I've only seen this for these two particular numbers.~ Same error with 3e-8 and 6e-8. Probably an unfortunate interaction between the truncation algorithm and certain inexact floating point representations.