JuliaString / Format.jl

A Julia package to provide C and Python-like formatting support
Other
40 stars 6 forks source link

Weird slash appears when formatting exponential notation #85

Open jagot opened 5 months ago

jagot commented 5 months ago

When formatting some numbers (I have only seen this for 1e-10) using exponential notation, a wild slash appears, see below:

julia> using Format

julia> format("{1:.16g}", 1e-10)
"1.000000000000000/e-10"

julia> format("{1:.16g}", 1e-5)
"1.0000000000000000e-05"

julia> format("{1:.17g}", 1e-10)
"1.00000000000000000e-10"

julia> format("{1:.17g}", 1e-5)
"1.00000000000000000e-05"

julia> format("{1:.16e}", 1e-10)
"1.000000000000000/e-10"

julia> format("{1:.16e}", 1e-9)
"1.0000000000000000e-09"

julia> format("{1:.16e}", 1e-10)
"1.000000000000000/e-10"

julia> format("{1:.16e}", 2e-10)
"1.9999999999999996e-10"

(tmp) pkg> st
Status `/private/tmp/Project.toml`
  [1fa38f19] Format v1.3.7

As seen above, I can somehow avoid it by increasing to 17 decimals, but it seems slightly arbitary.