Skip to content

Commit ef689cc

Browse files
authored
Merge pull request #163 from JuliaMath/oscardssmith-show-more-digits
use `compact=false` by default when printing.
2 parents cde8772 + 63f0b1a commit ef689cc

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/type/show.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ show(io::IO, ::Type{Double64}) = print(io, "Double64")
44
show(io::IO, ::Type{Double32}) = print(io, "Double32")
55

66
function show(io::IO, x::DoubleFloat{T}) where {T<:IEEEFloat}
7-
compact = get(io, :compact, true)
7+
compact = get(io, :compact, false)
88
if compact
99
str = string(x.hi)
1010
else
@@ -16,7 +16,7 @@ end
1616
function show(io::IO, x::Complex{DoubleFloat{T}}) where {T<:IEEEFloat}
1717
re, im = reim(x)
1818
imstr = isfinite(im) ? "im" : "*im"
19-
compact = get(io, :compact, true)
19+
compact = get(io, :compact, false)
2020
if compact
2121
str = string(HI(re), (signbit(x.im.hi) ? " - " : " + "), abs(HI(im)), imstr)
2222
else

test/string.jl

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
@testset "string" begin
1+
function test_string_and_show(x, s)
2+
b = IOBuffer()
3+
show(b, x)
4+
@test String(take!(b)) == string(x) == s
5+
end
26

3-
@test string(Double64(pi)) == "3.14159265358979323846264338327950588"
7+
@testset "string" begin
8+
test_string_and_show(Double64(pi), "3.14159265358979323846264338327950588")
49

5-
@test string(Double64(2.3045377697175683e-24, -1.5436846311151439e-40)) == "2.30453776971756809999999999999975586e-24"
10+
x = Double64(2.3045377697175683e-24, -1.5436846311151439e-40)
11+
test_string_and_show(x, "2.30453776971756809999999999999975586e-24")
612

7-
@test string(ComplexDF64(1.0,1.0)) == "1.0 + 1.0im"
13+
test_string_and_show(ComplexDF64(1.0,1.0), "1.0 + 1.0im")
14+
15+
x = Complex{Double64}(pi)+Double64(pi)*im
16+
test_string_and_show(x, "3.14159265358979323846264338327950588 + 3.14159265358979323846264338327950588im")
817

918
@test stringtyped(Double64(pi)) == "Double64(3.141592653589793, 1.2246467991473532e-16)"
1019

0 commit comments

Comments
 (0)