You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[I misspelt "too" in the title. Sorry! I don't know how to fix it.]
I'm quite surprised by this:
using Format
format("{1:.2g}", 0.00093) # -> "0.00"
whereas this Fortran program
program main
write(*,"(G0.2)") 0.00093d0 ! -> "0.93E-3"end program main
prints "0.93E-3".
I thought the whole point of the G format specifier is to minimize information loss while minimizing the horizontal space. Is Format.jl's behavior intended? or am I missing something?
I'll start looking at this now (I'd been ill for a while, didn't see this).
You can use the StrFormat.jl instead for now, i.e. f"\%.2g(0.00093)" which does give correct results.
(I inherited the python style formatting code from the now obsolete Formatting.jl, and it has two totally different code paths for the C style and the Python style formatting functions, unfortunately. Since I don't use the python style ones, I hadn't caught all of the errors in that code while trying to clean it up.
Activity
ScottPJones commentedon Oct 5, 2026
I'll start looking at this now (I'd been ill for a while, didn't see this).
You can use the StrFormat.jl instead for now, i.e.
f"\%.2g(0.00093)"which does give correct results.(I inherited the python style formatting code from the now obsolete Formatting.jl, and it has two totally different code paths for the C style and the Python style formatting functions, unfortunately. Since I don't use the python style ones, I hadn't caught all of the errors in that code while trying to clean it up.