Skip to content

Commit

Permalink
Fixed printing for Complex{Int} with maximum negative imaginary part …
Browse files Browse the repository at this point in the history
  • Loading branch information
lhnguyen-vn authored and JeffBezanson committed Oct 9, 2019
1 parent e0bdc76 commit b75fce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,16 @@ function show(io::IO, z::Complex)
compact = get(io, :compact, false)
show(io, r)
if signbit(i) && !isnan(i)
i = -i
print(io, compact ? "-" : " - ")
if isa(i,Signed) && !isa(i,BigInt) && i == typemin(typeof(i))
show(io, -widen(i))
else
show(io, -i)
end
else
print(io, compact ? "+" : " + ")
show(io, i)
end
show(io, i)
if !(isa(i,Integer) && !isa(i,Bool) || isa(i,AbstractFloat) && isfinite(i))
print(io, "*")
end
Expand Down
1 change: 1 addition & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ end
#show
@test sprint(show, complex(1, 0), context=:compact => true) == "1+0im"
@test sprint(show, complex(true, true)) == "Complex(true,true)"
@test sprint(show, Complex{Int8}(0, typemin(Int8))) == "0 - 128im"

@testset "unary operator on complex boolean" begin
@test +Complex(true, true) === Complex(1, 1)
Expand Down

0 comments on commit b75fce2

Please sign in to comment.