Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/fmtcore.jl
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,14 @@ function _pfmt_e(out::IO, fs::FormatSpec, x::AbstractFloat)
end

function _pfmt_g(out::IO, fs::FormatSpec, x::AbstractFloat)
# number decomposition
ax = abs(x)
if 1.0e-4 <= ax < 1.0e6
_pfmt_f(out, fs, x)
# Branch according to the exponent
expnt = floor(Int, log10(abs(x)) )
if -4 <= expnt < fs.prec
newprec = fs.prec - expnt - 1
_pfmt_f(out, FormatSpec(fs ;prec=newprec), x)
else
_pfmt_e(out, fs, x)
newprec = fs.prec - 1
_pfmt_e(out, FormatSpec(fs ;prec=newprec), x)
end
end

Expand Down
Loading