From ccf7fd7d46ca2ccfe71b1425e4feeb83fdb29bbb Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 1 Jul 2025 23:51:39 -0400 Subject: [PATCH 1/2] Update IntegerMathUtils.jl fixes https://github.com/JuliaMath/IntegerMathUtils.jl/issues/19 --- src/IntegerMathUtils.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/IntegerMathUtils.jl b/src/IntegerMathUtils.jl index b7b3e30..136b63f 100644 --- a/src/IntegerMathUtils.jl +++ b/src/IntegerMathUtils.jl @@ -8,7 +8,7 @@ iroot(x::T, n::Cint) where {T<:Integer} = T(iroot(big(x), Cint(n))) function iroot(x::BigInt, n::Cint) n <= 0 && throw(DomainError(n, "Exponent must be > 0")) - x <= 0 && iseven(x) && throw(DomainError(n, "This is a math no-no")) + x <= 0 && iseven(n) && throw(DomainError(n, "This is a math no-no")) ans = BigInt() @ccall :libgmp.__gmpz_root(ans::Ref{BigInt}, x::Ref{BigInt}, n::Cint)::Cint ans From b090ba058784d10afb88886bf778f504af70d3f3 Mon Sep 17 00:00:00 2001 From: Oscar Smith Date: Tue, 1 Jul 2025 23:54:47 -0400 Subject: [PATCH 2/2] tests --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 1ff7da7..a945ba2 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -11,6 +11,8 @@ using Test, IntegerMathUtils @test iroot(T(10000), 4) == T(10) @test iroot(T(10001), 4) == T(10) @test iroot(T(9999), 4) == T(9) + @test iroot(T(-8), 3) == T(-2) + @test_throws DomainError iroot(T(-8), 4) end @test iroot(big(23)^50, 50) == big(23) @test iroot(big(23)^50 + 1, 50) == big(23)