Skip to content

Commit 5a98d42

Browse files
committed
fixed show for 0
1 parent bb8354b commit 5a98d42

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MultiplesOfPi"
22
uuid = "b749d01f-fee9-4313-9f11-89ddf7ea9d58"
33
authors = ["Jishnu Bhattacharya", "Center for Space Science", "New York University Abu Dhabi"]
4-
version = "0.2.0"
4+
version = "0.2.1"
55

66
[compat]
77
julia = "1"

src/MultiplesOfPi.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ Base.convert(::Type{PiTimes{T}},p::PiTimes) where {T} = PiTimes{T}(p.x)
124124

125125
function Base.show(io::IO,p::PiTimes)
126126
pxstr = isone(p.x) ? "" : string(p.x)
127-
print(io,pxstr,"Pi")
127+
str = iszero(p) ? string(p.x) : pxstr*"Pi"
128+
print(io,str)
128129
end
129130

130131
end # module

test/runtests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,4 +346,10 @@ end
346346
@test String(take!(io)) == "Pi"
347347
show(io,2Pi)
348348
@test String(take!(io)) == "2Pi"
349+
show(io,0*Pi)
350+
@test String(take!(io)) == "0"
351+
show(io,im*Pi)
352+
@test String(take!(io)) == "0 + Pi*im"
353+
show(io,Pi + im*(2//3)Pi)
354+
@test String(take!(io)) == "Pi + 2//3Pi*im"
349355
end

0 commit comments

Comments
 (0)