user=> (bigint 30) 30 ;; Actually do something BigInteger-ish... (http://download.oracle.com/javase/6/docs/api/) user=> (def x (bigint 97)) #'user/x user=> (.isProbablePrime x 1) true
(defn bigint
"Coerce to BigInt"
{:tag clojure.lang.BigInt
:static true
:added "1.3"}
[x] (cond
(instance? clojure.lang.BigInt x) x
(instance? BigInteger x) (clojure.lang.BigInt/fromBigInteger x)
(decimal? x) (bigint (.toBigInteger ^BigDecimal x))
(ratio? x) (bigint (.bigIntegerValue ^clojure.lang.Ratio x))
(number? x) (clojure.lang.BigInt/valueOf (long x))
:else (bigint (BigInteger. x))))
Comments top
No comments for bigint. Log in to add a comment.