You're viewing version 1.2.0 of bigint. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

bigint

clojure.core

  • (bigint x)
Coerce to BigInteger

1 Example top

  • 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
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:2779 top

(defn bigint
  "Coerce to BigInteger"
  {:tag BigInteger
   :added "1.0"}
  [x] (cond
       (instance? BigInteger x) x
       (decimal? x) (.toBigInteger ^BigDecimal x)
       (ratio? x) (.bigIntegerValue ^clojure.lang.Ratio x)
       (number? x) (BigInteger/valueOf (long x))
       :else (BigInteger. x)))
Vars in clojure.core/bigint: cond decimal? defn instance? long number? ratio?
Used in 0 other vars

Comments top

No comments for bigint. Log in to add a comment.