1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00
This commit is contained in:
Michael Mclaughlin 2017-12-10 18:32:38 +00:00
parent fd668fea70
commit dbf681be4a
10 changed files with 39 additions and 29 deletions

View File

@ -1,6 +1,7 @@
language: node_js language: node_js
node_js: node_js:
- "node" - "node"
- "9"
- "8" - "8"
- "7" - "7"
- "6" - "6"

View File

@ -1,3 +1,10 @@
#### 8.0.0
* 10/12/2017
* Correct typings: `toFraction` returns `Decimal[]`.
* Type-checking: add `Decimal.isDecimal` method.
* Enable configuration reset with `defaults: true`.
* Add named export, Decimal, to *decimal.mjs*.
#### 7.5.1 #### 7.5.1
* 03/12/2017 * 03/12/2017
* Remove typo. * Remove typo.

View File

@ -30,32 +30,36 @@ 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 which makes it a significantly larger library than *bignumber.js* and the even smaller
[big.js](https://github.com/MikeMcl/big.js/). [big.js](https://github.com/MikeMcl/big.js/).
For a lighter version of this library without the trigonometric functions see the For a lighter version of this library without the trigonometric functions see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/).
[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 ## Load
The library is the single JavaScript file *decimal.js* (or minified, *decimal.min.js*, or *decimal.mjs* if ES6 modules are supported). The library is the single JavaScript file *decimal.js* (or minified, *decimal.min.js*).
It can be loaded using a script tag in an HTML document for the browser Browser:
```html ```html
<script src='path/to/decimal.js'></script> <script src='path/to/decimal.js'></script>
``` ```
or as a [Node.js](http://nodejs.org) module using `require`. [Node.js](http://nodejs.org):
```bash
$ npm install --save decimal.js
```
```js ```js
var Decimal = require('decimal.js'); var Decimal = require('decimal.js');
``` ```
For Node, the library is available from the [npm](https://npmjs.org/) registry ES6 module (*decimal.mjs*):
```bash ```js
$ npm install decimal.js //import Decimal from 'decimal.js';
import {Decimal} from 'decimal.js';
``` ```
To load with AMD loader libraries such as [requireJS](http://requirejs.org/): AMD loader libraries such as [requireJS](http://requirejs.org/):
```js ```js
require(['decimal'], function(Decimal) { require(['decimal'], function(Decimal) {
@ -163,13 +167,13 @@ applies to all Decimal numbers created from it.
Decimal.set({ precision: 5, rounding: 4 }) Decimal.set({ precision: 5, rounding: 4 })
// Create another Decimal constructor, optionally passing in a configuration object // Create another Decimal constructor, optionally passing in a configuration object
Decimal10 = Decimal.clone({ precision: 10, rounding: 1 }) Decimal9 = Decimal.clone({ precision: 9, rounding: 1 })
x = new Decimal(5) x = new Decimal(5)
y = new Decimal10(5) y = new Decimal9(5)
x.div(3) // '1.6667' x.div(3) // '1.6667'
y.div(3) // '1.666666666' y.div(3) // '1.66666666'
``` ```
The value of a Decimal is stored in a floating point format in terms of its digits, exponent and sign. The value of a Decimal is stored in a floating point format in terms of its digits, exponent and sign.

View File

@ -1,7 +1,7 @@
{ {
"name": "decimal.js", "name": "decimal.js",
"main": "decimal.js", "main": "decimal.js",
"version": "7.5.1", "version": "8.0.0",
"homepage": "https://github.com/MikeMcl/decimal.js", "homepage": "https://github.com/MikeMcl/decimal.js",
"authors": [ "authors": [
"Michael Mclaughlin <M8ch88l@gmail.com>" "Michael Mclaughlin <M8ch88l@gmail.com>"

4
decimal.d.ts vendored
View File

@ -313,8 +313,8 @@ export declare class Decimal {
static tanh(n: DecimalValue): Decimal static tanh(n: DecimalValue): Decimal
static trunc(n: DecimalValue): Decimal static trunc(n: DecimalValue): Decimal
static readonly default: DecimalConstructor; static readonly default?: DecimalConstructor;
static readonly Decimal: DecimalConstructor; static readonly Decimal?: DecimalConstructor;
static readonly precision: number; static readonly precision: number;
static readonly rounding: DecimalRounding; static readonly rounding: DecimalRounding;

View File

@ -1,10 +1,10 @@
/*! decimal.js v7.5.1 https://github.com/MikeMcl/decimal.js/LICENCE */ /*! decimal.js v8.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */
;(function (globalScope) { ;(function (globalScope) {
'use strict'; 'use strict';
/* /*
* decimal.js v7.5.1 * decimal.js v8.0.0
* An arbitrary-precision Decimal type for JavaScript. * An arbitrary-precision Decimal type for JavaScript.
* https://github.com/MikeMcl/decimal.js * https://github.com/MikeMcl/decimal.js
* Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com> * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>

4
decimal.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
/* /*
* *
* decimal.js v7.5.1 * decimal.js v8.0.0
* An arbitrary-precision Decimal type for JavaScript. * An arbitrary-precision Decimal type for JavaScript.
* https://github.com/MikeMcl/decimal.js * https://github.com/MikeMcl/decimal.js
* Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com> * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
@ -97,7 +97,7 @@ var EXP_LIMIT = 9e15, // 0 to 9e15
// ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- // // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
Decimal, inexact, quadrant, inexact, quadrant,
external = true, external = true,
decimalError = '[DecimalError] ', decimalError = '[DecimalError] ',
@ -4790,9 +4790,7 @@ function trunc(x) {
// Create and configure initial Decimal constructor. // Create and configure initial Decimal constructor.
Decimal = clone(DEFAULTS); export const Decimal = clone(DEFAULTS);
Decimal['default'] = Decimal.Decimal = Decimal;
// Create the internal constants from their string values. // Create the internal constants from their string values.
LN10 = new Decimal(LN10); LN10 = new Decimal(LN10);

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{ {
"name": "decimal.js", "name": "decimal.js",
"description": "An arbitrary-precision Decimal type for JavaScript.", "description": "An arbitrary-precision Decimal type for JavaScript.",
"version": "7.5.1", "version": "8.0.0",
"keywords": [ "keywords": [
"arbitrary", "arbitrary",
"precision", "precision",
@ -20,8 +20,8 @@
"type": "git", "type": "git",
"url": "https://github.com/MikeMcl/decimal.js.git" "url": "https://github.com/MikeMcl/decimal.js.git"
}, },
"main": "decimal.js", "main": "./decimal",
"module": "decimal.mjs", "module": "./decimal.mjs",
"author": { "author": {
"name": "Michael Mclaughlin", "name": "Michael Mclaughlin",
"email": "M8ch88l@gmail.com" "email": "M8ch88l@gmail.com"
@ -29,7 +29,7 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "node ./test/test.js", "test": "node ./test/test.js",
"build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v7.5.1 https://github.com/MikeMcl/decimal.js/LICENCE */\"" "build": "uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble \"/* decimal.js v8.0.0 https://github.com/MikeMcl/decimal.js/LICENCE */\""
}, },
"types": "decimal.d.ts" "types": "decimal.d.ts"
} }