Bug in Printf?

Is the following a bug in Printf?

julia> using Printf

julia> @sprintf "%8.3g" 1.99e-5

julia> @sprintf "%8.3g" 1.999e-5

I would expect the resulting string to be 8 characters long in both cases, while in the second it is only 5 characters long. It looks like @sprintf is eating leading blanks.

For comparison, here’s the output from C’s printf:


Should I submit a issue?

printf minimum width issue with %g · Issue #16977 · JuliaLang/julia · GitHub maybe.

Yes, it seems the same bug. Thank you.