Skip to content

Commit

Permalink
Fix depwarns on 0.7 (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao authored and ararslan committed Sep 13, 2017
1 parent 2267021 commit acc31a4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.5
Compat 0.18.0
Compat 0.30.0
15 changes: 10 additions & 5 deletions src/Primes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ julia> isprime(big(3))
true
```
"""
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp), Cint, (Ptr{BigInt}, Cint), &x, reps) > 0
isprime(x::BigInt, reps=25) = ccall((:__gmpz_probab_prime_p,:libgmp),
Cint, (Any, Cint), x, reps) > 0
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.


# Miller-Rabin witness choices based on:
Expand Down Expand Up @@ -535,10 +538,12 @@ end

# modify a BigInt in-place
function add_!(n::BigInt, x::Int)
# TODO: Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
# The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
if x < 0
ccall((:__gmpz_sub_ui, :libgmp), Void, (Ptr{BigInt}, Ptr{BigInt}, Culong), &n, &n, -x)
ccall((:__gmpz_sub_ui, :libgmp), Void, (Any, Any, Culong), n, n, -x)
else
ccall((:__gmpz_add_ui, :libgmp), Void, (Ptr{BigInt}, Ptr{BigInt}, Culong), &n, &n, x)
ccall((:__gmpz_add_ui, :libgmp), Void, (Any, Any, Culong), n, n, x)
end
n
end
Expand Down Expand Up @@ -571,7 +576,7 @@ julia> nextprime(5, 2)
"""
function nextprime(n::Integer, i::Integer=1)
i < 0 && return prevprime(n, -i)
i == 0 && throw(DomainError())
i == 0 && throw(DomainError(i))
n < 2 && (n = oftype(n, 2))
if n == 2
if i <= 1
Expand Down Expand Up @@ -646,7 +651,7 @@ julia> prime(3)
```
"""
prime{T<:Integer}(::Type{T}, i::Integer) = i < 0 ? throw(DomainError()) : nextprime(T(2), i)
prime{T<:Integer}(::Type{T}, i::Integer) = i < 0 ? throw(DomainError(i)) : nextprime(T(2), i)
prime(i::Integer) = prime(Int, i)

end # module
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ end
@test totient(2^4 * 3^4 * 5^4) == 216000
@test totient(big"2"^1000) == big"2"^999

const some_coprime_numbers = BigInt[
some_coprime_numbers = BigInt[
450000000, 1099427429702334733, 200252151854851, 1416976291499, 7504637909,
1368701327204614490999, 662333585807659, 340557446329, 1009091
]
Expand Down

0 comments on commit acc31a4

Please sign in to comment.