julia icon indicating copy to clipboard operation
julia copied to clipboard

the `//(::Number, ::Complex)` method is not correct when the second argument is zero or infinite

Open nsajko opened this issue 1 year ago • 0 comments

This is the method:

https://github.com/JuliaLang/julia/blob/877de9839809e769d4f9707a61df3400d087d8d3/base/rational.jl#L101-L101

The math behind the transformation incorrectly assumes y is finite and nonzero.

xref #53435, which concerns overflow caused by the same oneliner.

Test:

using Test

@testset "exact division by an infinite complex number" begin
    for y ∈ (1 // 0, -1 // 0)
        @test (7 // complex(y)) == (7 // y)
    end
end

Resulting in:

Test Summary:                                       | Error  Total  Time
exact division by a zero or infinite complex number |     3      3  1.6s
ERROR: Some tests did not pass: 0 passed, 0 failed, 3 errored, 0 broken.

nsajko avatar Oct 19 '24 16:10 nsajko