Skip to content

Commit 3c88392

Browse files
committed
type conversion for formatting methods
1 parent d2dafff commit 3c88392

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/fmtcore.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ end
265265

266266
function _pfmt_Number_f(out::IO, fs::FormatSpec, x::Number, _pf::Function)
267267
fsi = FormatSpec(fs, width = -1)
268-
f = x::AbstractFloat->begin
268+
f = x->begin
269+
fx = AbstractFloat(x) # not float(x), this should error out, if conversion is not possible
269270
io = IOBuffer()
270-
_pf(io, fsi, x)
271+
_pf(io, fsi, fx)
271272
String(take!(io))
272273
end
273274
s = fmt_Number(x, f)
@@ -276,9 +277,10 @@ end
276277

277278
function _pfmt_Number_i(out::IO, fs::FormatSpec, x::Number, op::Op, _pf::Function) where {Op}
278279
fsi = FormatSpec(fs, width = -1)
279-
f = x::Integer->begin
280+
f = x->begin
281+
ix = Integer(x)
280282
io = IOBuffer()
281-
_pf(io, fsi, x, op)
283+
_pf(io, fsi, ix, op)
282284
String(take!(io))
283285
end
284286
s = fmt_Number(x, f)

0 commit comments

Comments
 (0)