Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,7 @@ function Base.://(x::Rational{BigInt}, y::Rational{BigInt})
if iszero(x.num)
throw(DivideError())
end
return (isneg(x.num) ? -one(BigFloat) : one(BigFloat)) // y.num
return (isneg(x.num) ? -one(BigInt) : one(BigInt)) // y.num
end
zq = _MPQ()
ccall((:__gmpq_div, :libgmp), Cvoid,
Expand Down
12 changes: 12 additions & 0 deletions test/gmp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ ee = typemax(Int64)
@test big(typeof(complex(x, x))) == typeof(big(complex(x, x)))
end
end
@testset "division" begin
oz = big(1 // 0)
zo = big(0 // 1)

@test_throws DivideError() oz / oz
@test oz == oz / one(oz)
@test -oz == oz / (-one(oz))
@test zero(oz) == one(oz) / oz
@test_throws DivideError() zo / zo
@test one(zo) / zo == big(1//0)
@test -one(zo) / zo == big(-1//0)
end
end
@testset "div, fld, mod, rem" begin
for i = -10:10, j = [-10:-1; 1:10]
Expand Down