store/[org.clojure/clojure "1.8.0"] clj::clojure.core/bigint

Official Documentation

Add notes
Arities
==================================================
   [x]

Docstring
==================================================
  Coerce to BigInt

Source

(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))
       (float? x)  (bigint (. BigDecimal valueOf (double x)))
       (ratio? x) (bigint (.bigIntegerValue ^clojure.lang.Ratio x))
       (number? x) (clojure.lang.BigInt/valueOf (long x))
       :else (bigint (BigInteger. x))))

Example 1

Edit
(= (bigint 42) (clojure.lang.BigInt/fromBigInteger (BigInteger. "42")))
;; => true

(= 42N (bigint 42))
;; => true

(= 42 (bigint 42))
;; => true

(= 42 (clojure.lang.BigInt/fromBigInteger (BigInteger. "42")))
;; => true

Example 2

Edit
(reduce * (repeat 20 1000))
;; => ArithmeticException integer overflow  clojure.lang.Numbers.throwIntOverflow (Numbers.java:1388)

(reduce * (repeat 20 (bigint 1000)))
;; => 1000000000000000000000000000000000000000000000000000000000000N

Example 3

Edit
(bigint 30)
;; => 30

;; Actually do something BigInteger-ish... (http://download.oracle.com/javase/6/docs/api/)
(def x (bigint 97))
;; => #'user/x

(.isProbablePrime (.toBigInteger x) 100)
;; => true

Uses on crossclj