1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2026-09-23 12:24:47 +00:00
This commit is contained in:
Michael Mclaughlin
2016-11-09 17:08:38 +00:00
parent 46b1aad320
commit e48bddf45a
11 changed files with 171 additions and 167 deletions

View File

@@ -4,10 +4,6 @@ An arbitrary-precision Decimal type for JavaScript.
<br>
[![Build Status](https://travis-ci.org/MikeMcl/decimal.js.svg)](https://travis-ci.org/MikeMcl/decimal.js)
*For a smaller library without the trigonometric functions see the
[v4.x.x](https://github.com/MikeMcl/decimal.js/tree/v4.x.x) branch where version 4 of this library
continues to be supported, or see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/), which is smaller still.*
<br>
## Features
@@ -24,7 +20,7 @@ continues to be supported, or see [decimal.js-light](https://github.com/MikeMcl/
![API](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/API.png)
The library is similar to [bignumber.js](https://github.com/MikeMcl/bignumber.js/), but here
precision is specified in terms of significant digits instead of decimal places, and all
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.
@@ -32,6 +28,9 @@ This library also adds the trigonometric functions, among others, and supports n
which makes it a significantly larger library than *bignumber.js* and the even smaller
[big.js](https://github.com/MikeMcl/big.js/).
For a lighter version of this library without the trigonometric functions see the
[v4.x.x](https://github.com/MikeMcl/decimal.js/tree/v4.x.x) branch where version 4 continues to be supported, or better, see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/), which is lighter still.
## Load
The library is the single JavaScript file *decimal.js* (or minified, *decimal.min.js*).
@@ -153,7 +152,7 @@ applies to all Decimal numbers created from it.
```js
// Set the precision and rounding of the default Decimal constructor
Decimal.config({ precision: 5, rounding: 4 })
Decimal.set({ precision: 5, rounding: 4 })
// Create another Decimal constructor, optionally passing in a configuration object
Decimal10 = Decimal.clone({ precision: 10, rounding: 1 })
@@ -217,6 +216,7 @@ npm run build
will create *decimal.min.js*, and a source map will also be added to the *doc* directory.
## Feedback
<a href='mailto:M8ch88l@gmail.com'>M8ch88l@gmail.com</a>
@@ -225,6 +225,6 @@ BTC 16MjxmTB5EZxY5Uk9xyhfsu4n9gYxEJYkY
## Licence
MIT Expat.
MIT.
See *LICENCE.md*