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
node_js:
- "node"
- "9"
- "8"
- "7"
- "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
* 03/12/2017
* 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
[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.
For a lighter version of this library without the trigonometric functions see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/).
## 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
<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
var Decimal = require('decimal.js');
```
For Node, the library is available from the [npm](https://npmjs.org/) registry
ES6 module (*decimal.mjs*):
```bash
$ npm install decimal.js
```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
require(['decimal'], function(Decimal) {
@ -163,13 +167,13 @@ applies to all Decimal numbers created from it.
Decimal.set({ precision: 5, rounding: 4 })
// 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)
y = new Decimal10(5)
y = new Decimal9(5)
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.

View File

@ -1,7 +1,7 @@
{
"name": "decimal.js",
"main": "decimal.js",
"version": "7.5.1",
"version": "8.0.0",
"homepage": "https://github.com/MikeMcl/decimal.js",
"authors": [
"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 trunc(n: DecimalValue): Decimal
static readonly default: DecimalConstructor;
static readonly Decimal: DecimalConstructor;
static readonly default?: DecimalConstructor;
static readonly Decimal?: DecimalConstructor;
static readonly precision: number;
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) {
'use strict';
/*
* decimal.js v7.5.1
* decimal.js v8.0.0
* An arbitrary-precision Decimal type for JavaScript.
* https://github.com/MikeMcl/decimal.js
* 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.
* https://github.com/MikeMcl/decimal.js
* Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
@ -97,7 +97,7 @@ var EXP_LIMIT = 9e15, // 0 to 9e15
// ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
Decimal, inexact, quadrant,
inexact, quadrant,
external = true,
decimalError = '[DecimalError] ',
@ -4790,9 +4790,7 @@ function trunc(x) {
// Create and configure initial Decimal constructor.
Decimal = clone(DEFAULTS);
Decimal['default'] = Decimal.Decimal = Decimal;
export const Decimal = clone(DEFAULTS);
// Create the internal constants from their string values.
LN10 = new Decimal(LN10);

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,7 @@
{
"name": "decimal.js",
"description": "An arbitrary-precision Decimal type for JavaScript.",
"version": "7.5.1",
"version": "8.0.0",
"keywords": [
"arbitrary",
"precision",
@ -20,8 +20,8 @@
"type": "git",
"url": "https://github.com/MikeMcl/decimal.js.git"
},
"main": "decimal.js",
"module": "decimal.mjs",
"main": "./decimal",
"module": "./decimal.mjs",
"author": {
"name": "Michael Mclaughlin",
"email": "M8ch88l@gmail.com"
@ -29,7 +29,7 @@
"license": "MIT",
"scripts": {
"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"
}