Skip to content

Commit 4bf22f3

Browse files
committed
Make isimag return false for real numbers that are zero.
1 parent 74936b5 commit 4bf22f3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

base/complex.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ isreal(z::Complex) = iszero(imag(z))
9292
9393
Test whether `z` is purely imaginary, i.e. has a real part equal to 0.
9494
"""
95-
isimag(z::Number) = iszero(real(z))
95+
isimag(z::Real) = false
96+
isimag(z::Complex) = iszero(real(z))
9697
isinteger(z::Complex) = isreal(z) & isinteger(real(z))
9798
isfinite(z::Complex) = isfinite(real(z)) & isfinite(imag(z))
9899
isnan(z::Complex) = isnan(real(z)) | isnan(imag(z))

test/complex.jl

+3
Original file line numberDiff line numberDiff line change
@@ -969,3 +969,6 @@ end
969969

970970
# issue #19240
971971
@test big(1)/(10+10im) (5-5im)/big(100) big"0.05" - big"0.05"*im
972+
973+
# Test that isimag yields false for real numbers that are zero
974+
@test !isimag(0)

0 commit comments

Comments
 (0)