Skip to content

Commit 3af9170

Browse files
authored
Fix bug where 1.0 == big(1//0) throws (#59715)
Fixup for #58217 Found and fix proposed by Eric Demer
1 parent 7a8cd6e commit 3af9170

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

base/rational.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ fma(x::Rational, y::Rational, z::Rational) = x*y+z
443443

444444
function ==(x::AbstractFloat, q::Rational)
445445
if isfinite(x)
446-
(count_ones(q.den) == 1) & (ldexp(x, top_set_bit(q.den-1)) == q.num)
446+
(count_ones(q.den) == 1) && (ldexp(x, top_set_bit(q.den-1)) == q.num)
447447
else
448448
x == q.num/q.den
449449
end

test/rational.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,9 @@ end
853853
end
854854
end
855855

856-
@testset "Float16 comparison" begin
856+
@testset "Float-Rational comparison" begin
857857
@test Float16(6.0e-8) == big(1//16777216) == 1//16777216
858858
@test Float16(6.0e-8) == 1//16777216
859+
@test 1.0 != big(1//0)
860+
@test Inf == big(1//0)
859861
end

0 commit comments

Comments
 (0)