Skip to content

Files

Latest commit

 

History

History

decimal

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

cljsjs/decimal

[cljsjs/decimal "10.2.0-0"] ;; latest release

This jar comes with deps.cljs as used by the Foreign Libs feature of the ClojureScript compiler. After adding the above dependency to your project you can require the packaged library like so:

(ns application.core
  (:require cljsjs.decimal))

This package also supports :global-exports:

(ns application.core
  (:require ["decimal.js" :as decimal]))

The library is similar to bignumber.js, but here precision is specified in terms of significant digits rather than decimal places, and all calculations are rounded to the precision (similar to Python's decimal module) rather than just those involving division.

This library also adds the trigonometric functions, among others, and supports non-integer powers, which makes it a significantly larger library than bignumber.js and the even smaller big.js.

Example usage from Clojurescript:

(ns example.core
  (:require ["decimal.js" :as decimal]))

(extend-type decimal
  IEquiv
  (-equiv [this other]
    (.equals this other)))

(let [x (decimal. 123.4567)
      y (decimal. "123456.7e-3")
      z (decimal. x)]
  (= x y z))
;; => true