From 5b1d073e25c0f16c81604ee324424191778054ad Mon Sep 17 00:00:00 2001 From: "Corey M. Hoffstein" Date: Tue, 6 Mar 2012 11:28:57 -0500 Subject: [PATCH] Added sqrt interface for BigInt --- jl/bigint.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jl/bigint.jl b/jl/bigint.jl index 04b4ff1cd6309..609dec323d312 100644 --- a/jl/bigint.jl +++ b/jl/bigint.jl @@ -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