Skip to content

Commit

Permalink
Merge pull request #527 from choffstein/patch-1
Browse files Browse the repository at this point in the history
Added sqrt interface for BigInt
  • Loading branch information
StefanKarpinski committed Mar 6, 2012
2 parents 0a29305 + 5b1d073 commit 47cdfde
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jl/bigint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ function cmp(x::BigInt, y::BigInt)
ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpz_cmp), Int, (Ptr{Void}, Ptr{Void}),x.mpz, y.mpz)
end

function sqrt(x::BigInt)
z = _jl_bigint_init()
ccall(dlsym(_jl_libgmp_wrapper, :_jl_mpz_sqrt), Void, (Ptr{Void}, Ptr{Void}),z,x.mpz)
BigInt(z)
end

==(x::BigInt, y::BigInt) = cmp(x,y) == 0
<=(x::BigInt, y::BigInt) = cmp(x,y) <= 0
>=(x::BigInt, y::BigInt) = cmp(x,y) >= 0
Expand Down

0 comments on commit 47cdfde

Please sign in to comment.