Skip to content

Commit 783608a

Browse files
authored
Fix 0.0 giving InexactError in g/G due to log10(0)
1 parent 04baaf3 commit 783608a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/fmtcore.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ end
333333

334334
function _pfmt_g(out::IO, fs::FormatSpec, x::AbstractFloat)
335335
# Branch according to the exponent
336-
expnt = floor(Int, log10(abs(x)) )
336+
expnt = x == 0 ? 0 : floor(Int, log10(abs(x)) )
337337
if -4 <= expnt < fs.prec
338338
newprec = fs.prec - expnt - 1
339339
_pfmt_f(out, FormatSpec(fs ;prec=newprec), x)

0 commit comments

Comments
 (0)