Home / Validation / decimal.js - an arbitrary-precision Decimal type
decimal.js - an arbitrary-precision Decimal type

decimal.js - an arbitrary-precision Decimal type

Download Demo
  • Overview
  • Documents
User Rating: 3.9/5 ( 1 votes)
Your Rating:

decimal.js is an arbitrary-precision Decimal type for JavaScript. 

Features

  • Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal
  • Simple API but full-featured
  • Replicates the toExponential, toFixed, toPrecision and toString methods of JavaScript's Number type
  • Includes a toFraction and correctly-rounded exp, ln, log and sqrt functions
  • Supports non-integer powers
  • Works with numbers with or without fraction digits in bases from 2 to 64 inclusive
  • No dependencies
  • Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only
  • Comprehensive documentation and test set
  • 8 KB minified and gzipped

API

The library is similar to bignumber.js, but here precision is specified in terms of significant digits instead of 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 exp, ln and log functions, among others, and supports non-integer powers.

Another major difference is that this library enables multiple Decimal constructors to be created each with their own configuration. This is, however, a significantly larger library than bignumber.js and the even smaller big.js.

Source: github.com

Scroll To Top