ClojureDocs

Nav

Namespaces

bigdec

clojure.core

Available since 1.0 (source)
  • (bigdec x)
Coerce to BigDecimal
4 Examples
user=> (bigdec 3.0)
3.0M

user=> (bigdec 5)
5M

user=> (bigdec -1)
-1M

user=> (bigdec -1.0)
-1.0M

; It also works for strings:
(bigdec "123.45") => 123.45M
;; Works with ratios too

user => (bigdec 1/2)
;; 0.5M
user=> (+ 0.1 0.1 0.1)
0.30000000000000004
user=> (def a (bigdec 0.1))
#'user/a
user=> (+ a a a)
0.3M
See Also

Returns true if n is a BigDecimal

Added by alilee

Sets the precision and rounding mode to be used for BigDecimal operations. Usage: (with-precision...

Added by timgilbert

Coerce to BigInt

Added by Hindol

Coerce to double

Added by Hindol

Coerce to float

Added by Hindol
0 Notes
No notes for bigdec