Skip to content

Commit 9b397fa

Browse files
giordanoStefanKarpinski
authored andcommitted
Add tests for complex division corner cases, issue #22983 (#23013)
1 parent 738d042 commit 9b397fa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/complex.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,3 +974,16 @@ end
974974
" 1.0e-15+2.0im ",
975975
" 1.0+2.0e-15im"], "\n")
976976
end
977+
978+
@testset "corner cases of division, issue #22983" begin
979+
# These results abide by ISO/IEC 10967-3:2006(E) and
980+
# mathematical definition of division of complex numbers.
981+
for T in (Float32, Float64, BigFloat)
982+
@test isequal(one(T) / zero(Complex{T}), one(Complex{T}) / zero(Complex{T}))
983+
@test isequal(one(T) / zero(Complex{T}), Complex{T}(NaN, NaN))
984+
@test isequal(one(Complex{T}) / zero(T), Complex{T}(Inf, NaN))
985+
@test isequal(one(Complex{T}) / one(Complex{T}), one(Complex{T}))
986+
@test isequal(one(T) / complex(one(T), zero(T)), Complex(one(T), -zero(T)))
987+
@test isequal(one(T) / complex(one(T), -zero(T)), Complex(one(T), zero(T)))
988+
end
989+
end

0 commit comments

Comments
 (0)