Bug in Printf?


#1

Is the following a bug in Printf?

julia> using Printf

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

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

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:

1.99e-05
   2e-05

Should I submit a issue?


#2

https://github.com/JuliaLang/julia/issues/16977 maybe.


#3

Yes, it seems the same bug. Thank you.