Skip to content

g format loses to much information, #95

@ryofurue

Description

@ryofurue

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?

Format v1.3.7 on Julia 1.12.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions