@@ -178,7 +178,10 @@ julia> isprime(big(3))
178
178
true
179
179
```
180
180
"""
181
- isprime (x:: BigInt , reps= 25 ) = ccall ((:__gmpz_probab_prime_p ,:libgmp ), Cint, (Ptr{BigInt}, Cint), & x, reps) > 0
181
+ isprime (x:: BigInt , reps= 25 ) = ccall ((:__gmpz_probab_prime_p ,:libgmp ),
182
+ Cint, (Any, Cint), x, reps) > 0
183
+ # TODO : Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
184
+ # The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
182
185
183
186
184
187
# Miller-Rabin witness choices based on:
@@ -535,10 +538,12 @@ end
535
538
536
539
# modify a BigInt in-place
537
540
function add_! (n:: BigInt , x:: Int )
541
+ # TODO : Change `Any` to `Ref{BigInt}` when 0.6 support is dropped.
542
+ # The two have the same effect but `Ref{BigInt}` won't be optimized on 0.6.
538
543
if x < 0
539
- ccall ((:__gmpz_sub_ui , :libgmp ), Void, (Ptr{BigInt}, Ptr{BigInt} , Culong), & n, & n, - x)
544
+ ccall ((:__gmpz_sub_ui , :libgmp ), Void, (Any, Any , Culong), n, n, - x)
540
545
else
541
- ccall ((:__gmpz_add_ui , :libgmp ), Void, (Ptr{BigInt}, Ptr{BigInt} , Culong), & n, & n, x)
546
+ ccall ((:__gmpz_add_ui , :libgmp ), Void, (Any, Any , Culong), n, n, x)
542
547
end
543
548
n
544
549
end
@@ -571,7 +576,7 @@ julia> nextprime(5, 2)
571
576
"""
572
577
function nextprime (n:: Integer , i:: Integer = 1 )
573
578
i < 0 && return prevprime (n, - i)
574
- i == 0 && throw (DomainError ())
579
+ i == 0 && throw (DomainError (i ))
575
580
n < 2 && (n = oftype (n, 2 ))
576
581
if n == 2
577
582
if i <= 1
@@ -646,7 +651,7 @@ julia> prime(3)
646
651
647
652
```
648
653
"""
649
- prime {T<:Integer} (:: Type{T} , i:: Integer ) = i < 0 ? throw (DomainError ()) : nextprime (T (2 ), i)
654
+ prime {T<:Integer} (:: Type{T} , i:: Integer ) = i < 0 ? throw (DomainError (i )) : nextprime (T (2 ), i)
650
655
prime (i:: Integer ) = prime (Int, i)
651
656
652
657
end # module
0 commit comments