1.3.0 permalink Arrow_down_16x16

bigdec

clojure.core

  • (bigdec x)
Coerce to BigDecimal

1 Example top

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

(defn bigdec
  "Coerce to BigDecimal"
  {:tag BigDecimal
   :added "1.0"
   :static true}
  [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:
Used in 0 other vars

Comments top

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