Skip to content

Commit

Permalink
Make isimag return false for real numbers that are zero.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sacha0 committed Jan 8, 2017
1 parent 95072cd commit 3fc38cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ isreal(z::Complex) = iszero(imag(z))
Test whether `z` is purely imaginary, i.e. has a real part equal to 0.
"""
isimag(z::Number) = iszero(real(z))
isimag(z::Real) = false
isimag(z::Complex) = iszero(real(z))
isinteger(z::Complex) = isreal(z) & isinteger(real(z))
isfinite(z::Complex) = isfinite(real(z)) & isfinite(imag(z))
isnan(z::Complex) = isnan(real(z)) | isnan(imag(z))
Expand Down
3 changes: 3 additions & 0 deletions test/complex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -969,3 +969,6 @@ end

# issue #19240
@test big(1)/(10+10im) (5-5im)/big(100) big"0.05" - big"0.05"*im

# Test that isimag yields false for real numbers that are zero
@test !isimag(0)

0 comments on commit 3fc38cc

Please sign in to comment.