Support for CLJC arbitrary precision decimal numerics. CLJ support for BigDecimal works well, but it is not directly supported in CLJS. Use the support in this ns when you need to write CLJC code that works the same in both.
You MUST include big.js as a js dependency for this to compile in CLJS.
Support for CLJC arbitrary precision decimal numerics. CLJ support for BigDecimal works well, but it is not directly supported in CLJS. Use the support in this ns when you need to write CLJC code that works the same in both. You MUST include big.js as a js dependency for this to compile in CLJS.
(*)
(* & numbers)
Multiply the given numbers, using bigdecimal math
Multiply the given numbers, using bigdecimal math
(+)
(+ & numbers)
Add the given numbers together, coercing any that are not numeric.
Add the given numbers together, coercing any that are not numeric.
(- & numbers)
Subtract the given numbers, using bigdecimal math
Subtract the given numbers, using bigdecimal math
(div n d)
(div n d precision)
Divide the given two numbers, using bigdecimal math, with 20 digits
of precision. In primitive mode just uses regular /
.
Divide the given two numbers, using bigdecimal math, with 20 digits of precision. In primitive mode just uses regular `/`.
(floor n)
Returns the floor of n, which is n with all decimal digits removed.
Returns the floor of n, which is n with all decimal digits removed.
(negative n)
If n is positive then returns n*(-1) else returns n.
If n is positive then returns n*(-1) else returns n.
(negative? v)
Predicate for clj(s) negative bigdecimal
Predicate for clj(s) negative bigdecimal
(numeric s)
Coerce to a numeric from an arbitrary type (number, string, or numeric).
Coerce to a numeric from an arbitrary type (number, string, or numeric).
(numeric->currency-str n)
(numeric->currency-str n language country currency-code)
Convert a numeric into a locale-specific currency string. The defaults are en
, US
, and USD
.
Convert a numeric into a locale-specific currency string. The defaults are `en`, `US`, and `USD`.
(numeric->str bd)
Convert a math number to a string.
Convert a math number to a string.
(numeric? v)
Predicate for clj(s) dynamic number (n or bigdecimal). Returns true if the given value is a numeric in the current computing context (primitive or BigDecimal).
Predicate for clj(s) dynamic number (n or bigdecimal). Returns true if the given value is a numeric in the current computing context (primitive or BigDecimal).
(positive n)
If n is negative then returns n*(-1) else returns n.
If n is negative then returns n*(-1) else returns n.
(positive? v)
Predicate for clj(s) positive bigdecimal
Predicate for clj(s) positive bigdecimal
(round n decimal-digits)
Round the given number to the given number of decimal digits. Returns a new bigdecimal number.
n can be nil (returns 0), a numeric string, a regular number, or a bigdecimal.
Round the given number to the given number of decimal digits. Returns a new bigdecimal number. n can be nil (returns 0), a numeric string, a regular number, or a bigdecimal.
(with-primitive-ops & body)
Creates a thread-safe dynamic context where the math operations from this namespace use primitives instead of BigDecimal for speed.
Creates a thread-safe dynamic context where the math operations from this namespace use primitives instead of BigDecimal for speed.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close