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



  • (bigdec x)
Coerce to BigDecimal

1 Example top

  • user=> (bigdec 3.0)
    user=> (bigdec 5)
    user=> (bigdec -1)
    user=> (bigdec -1.0)
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:2790 top

(defn bigdec
  "Coerce to BigDecimal"
  {:tag BigDecimal
   :added "1.0"}
  [x] (cond
       (decimal? x) x
       (float? x) (. BigDecimal valueOf (double x))
       (ratio? x) (/ (BigDecimal. (.numerator x)) (.denominator x))
       (instance? BigInteger x) (BigDecimal. ^BigInteger x)
       (number? x) (BigDecimal/valueOf (long x))
       :else (BigDecimal. x)))
Vars in clojure.core/bigdec: / cond decimal? defn double float? instance? long number? ratio?
Used in 0 other vars

Comments top

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