From 1c280a7801852ff2dd854f3aa9d6907dfdff7fe3 Mon Sep 17 00:00:00 2001 From: Jacob Quinn Date: Thu, 19 Sep 2019 05:08:08 -0600 Subject: [PATCH] Fix #33262 by ensuring Base.print prints full precision for Float16/Float32, but doesn't include type info --- base/ryu/Ryu.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/base/ryu/Ryu.jl b/base/ryu/Ryu.jl index 93a2300a47582..ef2c105509726 100644 --- a/base/ryu/Ryu.jl +++ b/base/ryu/Ryu.jl @@ -101,10 +101,10 @@ function writeexp(x::T, return String(resize!(buf, pos - 1)) end -function Base.show(io::IO, x::T) where {T <: Base.IEEEFloat} +function Base.show(io::IO, x::T, forceuntyped::Bool=false) where {T <: Base.IEEEFloat} compact = get(io, :compact, false) buf = Base.StringVector(neededdigits(T)) - typed = !compact && get(io, :typeinfo, Any) != typeof(x) + typed = !forceuntyped && !compact && get(io, :typeinfo, Any) != typeof(x) pos = writeshortest(buf, 1, x, false, false, true, -1, x isa Float32 ? UInt8('f') : UInt8('e'), false, UInt8('.'), typed, compact) write(io, resize!(buf, pos - 1)) @@ -118,6 +118,6 @@ function Base.string(x::T) where {T <: Base.IEEEFloat} return String(resize!(buf, pos - 1)) end -Base.print(io::IO, x::Union{Float16, Float32}) = show(IOContext(io, :compact => true), x) +Base.print(io::IO, x::Union{Float16, Float32}) = show(io, x, true) end # module \ No newline at end of file