视频会议上传文件
This commit is contained in:
+146
-146
@@ -1,146 +1,146 @@
|
||||
#### 5.2.2
|
||||
|
||||
* 18/10/18
|
||||
* #109 Remove opencollective dependency.
|
||||
|
||||
#### 5.2.1
|
||||
|
||||
* Delete *bower.json*.
|
||||
|
||||
#### 5.2.0
|
||||
|
||||
* 09/10/18
|
||||
* #63 Allow negative argument for `round`.
|
||||
* #107 `sqrt` of large number.
|
||||
|
||||
#### 5.1.2
|
||||
|
||||
* 24/05/18
|
||||
* #95 Add `browser` field to *package.json*.
|
||||
* Restore named export to enable `import {Big}`.
|
||||
|
||||
#### 5.1.1
|
||||
|
||||
* 22/05/18
|
||||
* #95 Remove named export.
|
||||
|
||||
#### 5.1.0
|
||||
|
||||
* 22/05/18
|
||||
* Amend *.mjs* exports.
|
||||
* Remove extension from `main` field in *package.json*.
|
||||
|
||||
#### 5.0.3
|
||||
|
||||
* 23/10/17
|
||||
* #89 Optimisation of internal `round` function.
|
||||
|
||||
#### 5.0.2
|
||||
|
||||
* 13/10/17
|
||||
* Update *README.md*.
|
||||
|
||||
#### 5.0.1
|
||||
|
||||
* 13/10/17
|
||||
* Correct `Big.version` number.
|
||||
|
||||
#### 5.0.0
|
||||
|
||||
* 13/10/17
|
||||
* Return `-0` from `valueOf` for negative zero.
|
||||
* Refactor the methods which return a string.
|
||||
* Amend error messaging.
|
||||
* Update API document and change its colour scheme.
|
||||
* Add `Big.version`.
|
||||
* Remove bitcoin address.
|
||||
|
||||
#### 4.0.2
|
||||
|
||||
* 28/09/17
|
||||
* Add *big.mjs* for use with Node.js with `--experimental-modules` flag.
|
||||
|
||||
#### 4.0.0
|
||||
|
||||
* 27/09/17
|
||||
* Rename `Big.E_POS` to `Big.PE`, `Big.E_NEG` to `Big.NE`.
|
||||
* Refactor error messaging.
|
||||
* Throw if `null` is passed to `toFixed` etc.
|
||||
|
||||
#### 3.2.0
|
||||
|
||||
* 14/09/17 Aid ES6 import.
|
||||
|
||||
#### 3.1.3
|
||||
|
||||
* Minor documentation updates.
|
||||
|
||||
#### 3.1.2
|
||||
|
||||
* README typo.
|
||||
|
||||
#### 3.1.1
|
||||
|
||||
* API documentation update, including FAQ additions.
|
||||
|
||||
#### 3.1.0
|
||||
|
||||
* Renamed and exposed `TO_EXP_NEG` and `TO_EXP_POS` as `Big.E_NEG` and `Big.E_POS`.
|
||||
|
||||
#### 3.0.2
|
||||
|
||||
* Remove *.npmignore*, use `files` field in *package.json* instead.
|
||||
|
||||
#### 3.0.1
|
||||
|
||||
* Added `sub`, `add` and `mul` aliases.
|
||||
* Clean-up after lint.
|
||||
|
||||
#### 3.0.0
|
||||
|
||||
* 10/12/14 Added [multiple constructor functionality](http://mikemcl.github.io/big.js/#faq).
|
||||
* No breaking changes or other additions, but a major code reorganisation, so *v3* seemed appropiate.
|
||||
|
||||
#### 2.5.2
|
||||
|
||||
* 1/11/14 Added bower.json.
|
||||
|
||||
#### 2.5.1
|
||||
|
||||
* 8/06/14 Amend README requires.
|
||||
|
||||
#### 2.5.0
|
||||
|
||||
* 26/01/14 Added `toJSON` method so serialization uses `toString`.
|
||||
|
||||
#### 2.4.1
|
||||
|
||||
* 17/10/13 Conform signed zero to IEEEE 754 (2008).
|
||||
|
||||
#### 2.4.0
|
||||
|
||||
* 19/09/13 Throw instances of `Error`.
|
||||
|
||||
#### 2.3.0
|
||||
|
||||
* 16/09/13 Added `cmp` method.
|
||||
|
||||
#### 2.2.0
|
||||
|
||||
* 11/07/13 Added 'round up' mode.
|
||||
|
||||
#### 2.1.0
|
||||
|
||||
* 26/06/13 Allow e.g. `.1` and `2.`.
|
||||
|
||||
#### 2.0.0
|
||||
|
||||
* 12/05/13 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods.
|
||||
|
||||
#### 1.0.1
|
||||
|
||||
* Changed default value of MAX_DP to 1E6
|
||||
|
||||
#### 1.0.0
|
||||
|
||||
* 7/11/2012 Initial release
|
||||
#### 5.2.2
|
||||
|
||||
* 18/10/18
|
||||
* #109 Remove opencollective dependency.
|
||||
|
||||
#### 5.2.1
|
||||
|
||||
* Delete *bower.json*.
|
||||
|
||||
#### 5.2.0
|
||||
|
||||
* 09/10/18
|
||||
* #63 Allow negative argument for `round`.
|
||||
* #107 `sqrt` of large number.
|
||||
|
||||
#### 5.1.2
|
||||
|
||||
* 24/05/18
|
||||
* #95 Add `browser` field to *package.json*.
|
||||
* Restore named export to enable `import {Big}`.
|
||||
|
||||
#### 5.1.1
|
||||
|
||||
* 22/05/18
|
||||
* #95 Remove named export.
|
||||
|
||||
#### 5.1.0
|
||||
|
||||
* 22/05/18
|
||||
* Amend *.mjs* exports.
|
||||
* Remove extension from `main` field in *package.json*.
|
||||
|
||||
#### 5.0.3
|
||||
|
||||
* 23/10/17
|
||||
* #89 Optimisation of internal `round` function.
|
||||
|
||||
#### 5.0.2
|
||||
|
||||
* 13/10/17
|
||||
* Update *README.md*.
|
||||
|
||||
#### 5.0.1
|
||||
|
||||
* 13/10/17
|
||||
* Correct `Big.version` number.
|
||||
|
||||
#### 5.0.0
|
||||
|
||||
* 13/10/17
|
||||
* Return `-0` from `valueOf` for negative zero.
|
||||
* Refactor the methods which return a string.
|
||||
* Amend error messaging.
|
||||
* Update API document and change its colour scheme.
|
||||
* Add `Big.version`.
|
||||
* Remove bitcoin address.
|
||||
|
||||
#### 4.0.2
|
||||
|
||||
* 28/09/17
|
||||
* Add *big.mjs* for use with Node.js with `--experimental-modules` flag.
|
||||
|
||||
#### 4.0.0
|
||||
|
||||
* 27/09/17
|
||||
* Rename `Big.E_POS` to `Big.PE`, `Big.E_NEG` to `Big.NE`.
|
||||
* Refactor error messaging.
|
||||
* Throw if `null` is passed to `toFixed` etc.
|
||||
|
||||
#### 3.2.0
|
||||
|
||||
* 14/09/17 Aid ES6 import.
|
||||
|
||||
#### 3.1.3
|
||||
|
||||
* Minor documentation updates.
|
||||
|
||||
#### 3.1.2
|
||||
|
||||
* README typo.
|
||||
|
||||
#### 3.1.1
|
||||
|
||||
* API documentation update, including FAQ additions.
|
||||
|
||||
#### 3.1.0
|
||||
|
||||
* Renamed and exposed `TO_EXP_NEG` and `TO_EXP_POS` as `Big.E_NEG` and `Big.E_POS`.
|
||||
|
||||
#### 3.0.2
|
||||
|
||||
* Remove *.npmignore*, use `files` field in *package.json* instead.
|
||||
|
||||
#### 3.0.1
|
||||
|
||||
* Added `sub`, `add` and `mul` aliases.
|
||||
* Clean-up after lint.
|
||||
|
||||
#### 3.0.0
|
||||
|
||||
* 10/12/14 Added [multiple constructor functionality](http://mikemcl.github.io/big.js/#faq).
|
||||
* No breaking changes or other additions, but a major code reorganisation, so *v3* seemed appropiate.
|
||||
|
||||
#### 2.5.2
|
||||
|
||||
* 1/11/14 Added bower.json.
|
||||
|
||||
#### 2.5.1
|
||||
|
||||
* 8/06/14 Amend README requires.
|
||||
|
||||
#### 2.5.0
|
||||
|
||||
* 26/01/14 Added `toJSON` method so serialization uses `toString`.
|
||||
|
||||
#### 2.4.1
|
||||
|
||||
* 17/10/13 Conform signed zero to IEEEE 754 (2008).
|
||||
|
||||
#### 2.4.0
|
||||
|
||||
* 19/09/13 Throw instances of `Error`.
|
||||
|
||||
#### 2.3.0
|
||||
|
||||
* 16/09/13 Added `cmp` method.
|
||||
|
||||
#### 2.2.0
|
||||
|
||||
* 11/07/13 Added 'round up' mode.
|
||||
|
||||
#### 2.1.0
|
||||
|
||||
* 26/06/13 Allow e.g. `.1` and `2.`.
|
||||
|
||||
#### 2.0.0
|
||||
|
||||
* 12/05/13 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods.
|
||||
|
||||
#### 1.0.1
|
||||
|
||||
* Changed default value of MAX_DP to 1E6
|
||||
|
||||
#### 1.0.0
|
||||
|
||||
* 7/11/2012 Initial release
|
||||
|
||||
+23
-23
@@ -1,23 +1,23 @@
|
||||
The MIT Licence (Expat).
|
||||
|
||||
Copyright (c) 2018 Michael Mclaughlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
The MIT Licence (Expat).
|
||||
|
||||
Copyright (c) 2018 Michael Mclaughlin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
+201
-201
@@ -1,201 +1,201 @@
|
||||
# big.js
|
||||
|
||||
**A small, fast JavaScript library for arbitrary-precision decimal arithmetic.**
|
||||
|
||||
The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/) and [decimal.js](https://github.com/MikeMcl/decimal.js/). See [here](https://github.com/MikeMcl/big.js/wiki) for some notes on the difference between them.
|
||||
|
||||
## Features
|
||||
|
||||
- Faster, smaller and easier-to-use than JavaScript versions of Java's BigDecimal
|
||||
- Only 5.9 KB minified and 2.7 KB gzipped
|
||||
- Simple API
|
||||
- Replicates the `toExponential`, `toFixed` and `toPrecision` methods of JavaScript's Number type
|
||||
- Includes a `sqrt` method
|
||||
- Stores values in an accessible decimal floating point format
|
||||
- No dependencies
|
||||
- Comprehensive [documentation](http://mikemcl.github.io/big.js/) and test set
|
||||
|
||||
## Set up
|
||||
|
||||
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).
|
||||
|
||||
Browser:
|
||||
|
||||
```html
|
||||
<script src='path/to/big.js'></script>
|
||||
```
|
||||
|
||||
[Node.js](http://nodejs.org):
|
||||
|
||||
```bash
|
||||
$ npm install big.js
|
||||
```
|
||||
|
||||
```javascript
|
||||
const Big = require('big.js');
|
||||
```
|
||||
|
||||
ES6 module:
|
||||
|
||||
```javascript
|
||||
import Big from 'big.mjs';
|
||||
```
|
||||
## Use
|
||||
|
||||
*In all examples below, `var`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||
|
||||
The library exports a single function, `Big`, the constructor of Big number instances.
|
||||
It accepts a value of type number, string or Big number object.
|
||||
|
||||
x = new Big(123.4567)
|
||||
y = Big('123456.7e-3') // 'new' is optional
|
||||
z = new Big(x)
|
||||
x.eq(y) && x.eq(z) && y.eq(z) // true
|
||||
|
||||
A Big number is immutable in the sense that it is not changed by its methods.
|
||||
|
||||
0.3 - 0.1 // 0.19999999999999998
|
||||
x = new Big(0.3)
|
||||
x.minus(0.1) // "0.2"
|
||||
x // "0.3"
|
||||
|
||||
The methods that return a Big number can be chained.
|
||||
|
||||
x.div(y).plus(z).times(9).minus('1.234567801234567e+8').plus(976.54321).div('2598.11772')
|
||||
x.sqrt().div(y).pow(3).gt(y.mod(z)) // true
|
||||
|
||||
Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.
|
||||
|
||||
x = new Big(255.5)
|
||||
x.toExponential(5) // "2.55500e+2"
|
||||
x.toFixed(5) // "255.50000"
|
||||
x.toPrecision(5) // "255.50"
|
||||
|
||||
The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
|
||||
(with negative exponent), as these methods involve division.
|
||||
|
||||
The maximum number of decimal places and the rounding mode used to round the results of these methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor.
|
||||
|
||||
Big.DP = 10
|
||||
Big.RM = 1
|
||||
|
||||
x = new Big(2);
|
||||
y = new Big(3);
|
||||
z = x.div(y) // "0.6666666667"
|
||||
z.sqrt() // "0.8164965809"
|
||||
z.pow(-3) // "3.3749999995"
|
||||
z.times(z) // "0.44444444448888888889"
|
||||
z.times(z).round(10) // "0.4444444445"
|
||||
|
||||
Multiple Big number constructors can be created, each with an independent configuration.
|
||||
|
||||
The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||
|
||||
x = new Big(-123.456);
|
||||
x.c // [1,2,3,4,5,6] coefficient (i.e. significand)
|
||||
x.e // 2 exponent
|
||||
x.s // -1 sign
|
||||
|
||||
For further information see the [API](http://mikemcl.github.io/big.js/) reference from the *doc* folder.
|
||||
|
||||
## Test
|
||||
|
||||
The *test* directory contains the test scripts for each Big number method.
|
||||
|
||||
The tests can be run with Node.js or a browser.
|
||||
|
||||
To run all the tests
|
||||
|
||||
$ npm test
|
||||
|
||||
To test a single method
|
||||
|
||||
$ node test/toFixed
|
||||
|
||||
For the browser, see *single-test.html* and *every-test.html* in the *test/browser* directory.
|
||||
|
||||
*big-vs-number.html* is a simple application that enables some of the methods of big.js to be compared with those of JavaScript's Number type.
|
||||
|
||||
## Performance
|
||||
|
||||
The *perf* directory contains two legacy applications and a *lib* directory containing the BigDecimal libraries used by both.
|
||||
|
||||
*big-vs-bigdecimal.html* tests the performance of big.js against the JavaScript translations of two versions of BigDecimal, its use should be more or less self-explanatory.
|
||||
|
||||
* [GWT: java.math.BigDecimal](https://github.com/iriscouch/bigdecimal.js)
|
||||
* [ICU4J: com.ibm.icu.math.BigDecimal](https://github.com/dtrebbien/BigDecimal.js)
|
||||
|
||||
The BigDecimal in the npm registry is the GWT version. It has some bugs, see the Node.js script *perf/lib/bigdecimal_GWT/bugs.js* for examples of flaws in its *remainder*, *divide* and *compareTo* methods.
|
||||
|
||||
*bigtime.js* is a Node.js command-line application which tests the performance of big.js against the GWT version of
|
||||
BigDecimal from the npm registry.
|
||||
|
||||
For example, to compare the time taken by the big.js `plus` method and the BigDecimal `add` method
|
||||
|
||||
$ node bigtime plus 10000 40
|
||||
|
||||
This will time 10000 calls to each, using operands of up to 40 random digits and will check that the results match.
|
||||
|
||||
For help
|
||||
|
||||
$ node bigtime -h
|
||||
|
||||
## Build
|
||||
|
||||
If [uglify-js](https://github.com/mishoo/UglifyJS2) is installed globally
|
||||
|
||||
$ npm install uglify-js -g
|
||||
|
||||
then
|
||||
|
||||
$ npm run build
|
||||
|
||||
will create *big.min.js*.
|
||||
|
||||
## TypeScript
|
||||
|
||||
The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for big.js.
|
||||
|
||||
$ npm install @types/big.js
|
||||
|
||||
Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.
|
||||
|
||||
## Feedback
|
||||
|
||||
Bugs/comments/questions?
|
||||
|
||||
Open an issue, or email <a href="mailto:M8ch88l@gmail.com">Michael</a>
|
||||
|
||||
## Licence
|
||||
|
||||
[MIT](LICENCE)
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/bigjs/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bigjs#backer)]
|
||||
|
||||
<a href="https://opencollective.com/bigjs#backers" target="_blank"><img src="https://opencollective.com/bigjs/backers.svg?width=890"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bigjs#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/bigjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/4/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/5/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/6/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/7/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/8/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/9/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/9/avatar.svg"></a>
|
||||
|
||||
|
||||
# big.js
|
||||
|
||||
**A small, fast JavaScript library for arbitrary-precision decimal arithmetic.**
|
||||
|
||||
The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/) and [decimal.js](https://github.com/MikeMcl/decimal.js/). See [here](https://github.com/MikeMcl/big.js/wiki) for some notes on the difference between them.
|
||||
|
||||
## Features
|
||||
|
||||
- Faster, smaller and easier-to-use than JavaScript versions of Java's BigDecimal
|
||||
- Only 5.9 KB minified and 2.7 KB gzipped
|
||||
- Simple API
|
||||
- Replicates the `toExponential`, `toFixed` and `toPrecision` methods of JavaScript's Number type
|
||||
- Includes a `sqrt` method
|
||||
- Stores values in an accessible decimal floating point format
|
||||
- No dependencies
|
||||
- Comprehensive [documentation](http://mikemcl.github.io/big.js/) and test set
|
||||
|
||||
## Set up
|
||||
|
||||
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).
|
||||
|
||||
Browser:
|
||||
|
||||
```html
|
||||
<script src='path/to/big.js'></script>
|
||||
```
|
||||
|
||||
[Node.js](http://nodejs.org):
|
||||
|
||||
```bash
|
||||
$ npm install big.js
|
||||
```
|
||||
|
||||
```javascript
|
||||
const Big = require('big.js');
|
||||
```
|
||||
|
||||
ES6 module:
|
||||
|
||||
```javascript
|
||||
import Big from 'big.mjs';
|
||||
```
|
||||
## Use
|
||||
|
||||
*In all examples below, `var`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*
|
||||
|
||||
The library exports a single function, `Big`, the constructor of Big number instances.
|
||||
It accepts a value of type number, string or Big number object.
|
||||
|
||||
x = new Big(123.4567)
|
||||
y = Big('123456.7e-3') // 'new' is optional
|
||||
z = new Big(x)
|
||||
x.eq(y) && x.eq(z) && y.eq(z) // true
|
||||
|
||||
A Big number is immutable in the sense that it is not changed by its methods.
|
||||
|
||||
0.3 - 0.1 // 0.19999999999999998
|
||||
x = new Big(0.3)
|
||||
x.minus(0.1) // "0.2"
|
||||
x // "0.3"
|
||||
|
||||
The methods that return a Big number can be chained.
|
||||
|
||||
x.div(y).plus(z).times(9).minus('1.234567801234567e+8').plus(976.54321).div('2598.11772')
|
||||
x.sqrt().div(y).pow(3).gt(y.mod(z)) // true
|
||||
|
||||
Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.
|
||||
|
||||
x = new Big(255.5)
|
||||
x.toExponential(5) // "2.55500e+2"
|
||||
x.toFixed(5) // "255.50000"
|
||||
x.toPrecision(5) // "255.50"
|
||||
|
||||
The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
|
||||
(with negative exponent), as these methods involve division.
|
||||
|
||||
The maximum number of decimal places and the rounding mode used to round the results of these methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor.
|
||||
|
||||
Big.DP = 10
|
||||
Big.RM = 1
|
||||
|
||||
x = new Big(2);
|
||||
y = new Big(3);
|
||||
z = x.div(y) // "0.6666666667"
|
||||
z.sqrt() // "0.8164965809"
|
||||
z.pow(-3) // "3.3749999995"
|
||||
z.times(z) // "0.44444444448888888889"
|
||||
z.times(z).round(10) // "0.4444444445"
|
||||
|
||||
Multiple Big number constructors can be created, each with an independent configuration.
|
||||
|
||||
The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
|
||||
|
||||
x = new Big(-123.456);
|
||||
x.c // [1,2,3,4,5,6] coefficient (i.e. significand)
|
||||
x.e // 2 exponent
|
||||
x.s // -1 sign
|
||||
|
||||
For further information see the [API](http://mikemcl.github.io/big.js/) reference from the *doc* folder.
|
||||
|
||||
## Test
|
||||
|
||||
The *test* directory contains the test scripts for each Big number method.
|
||||
|
||||
The tests can be run with Node.js or a browser.
|
||||
|
||||
To run all the tests
|
||||
|
||||
$ npm test
|
||||
|
||||
To test a single method
|
||||
|
||||
$ node test/toFixed
|
||||
|
||||
For the browser, see *single-test.html* and *every-test.html* in the *test/browser* directory.
|
||||
|
||||
*big-vs-number.html* is a simple application that enables some of the methods of big.js to be compared with those of JavaScript's Number type.
|
||||
|
||||
## Performance
|
||||
|
||||
The *perf* directory contains two legacy applications and a *lib* directory containing the BigDecimal libraries used by both.
|
||||
|
||||
*big-vs-bigdecimal.html* tests the performance of big.js against the JavaScript translations of two versions of BigDecimal, its use should be more or less self-explanatory.
|
||||
|
||||
* [GWT: java.math.BigDecimal](https://github.com/iriscouch/bigdecimal.js)
|
||||
* [ICU4J: com.ibm.icu.math.BigDecimal](https://github.com/dtrebbien/BigDecimal.js)
|
||||
|
||||
The BigDecimal in the npm registry is the GWT version. It has some bugs, see the Node.js script *perf/lib/bigdecimal_GWT/bugs.js* for examples of flaws in its *remainder*, *divide* and *compareTo* methods.
|
||||
|
||||
*bigtime.js* is a Node.js command-line application which tests the performance of big.js against the GWT version of
|
||||
BigDecimal from the npm registry.
|
||||
|
||||
For example, to compare the time taken by the big.js `plus` method and the BigDecimal `add` method
|
||||
|
||||
$ node bigtime plus 10000 40
|
||||
|
||||
This will time 10000 calls to each, using operands of up to 40 random digits and will check that the results match.
|
||||
|
||||
For help
|
||||
|
||||
$ node bigtime -h
|
||||
|
||||
## Build
|
||||
|
||||
If [uglify-js](https://github.com/mishoo/UglifyJS2) is installed globally
|
||||
|
||||
$ npm install uglify-js -g
|
||||
|
||||
then
|
||||
|
||||
$ npm run build
|
||||
|
||||
will create *big.min.js*.
|
||||
|
||||
## TypeScript
|
||||
|
||||
The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for big.js.
|
||||
|
||||
$ npm install @types/big.js
|
||||
|
||||
Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.
|
||||
|
||||
## Feedback
|
||||
|
||||
Bugs/comments/questions?
|
||||
|
||||
Open an issue, or email <a href="mailto:M8ch88l@gmail.com">Michael</a>
|
||||
|
||||
## Licence
|
||||
|
||||
[MIT](LICENCE)
|
||||
|
||||
## Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="graphs/contributors"><img src="https://opencollective.com/bigjs/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
|
||||
## Backers
|
||||
|
||||
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bigjs#backer)]
|
||||
|
||||
<a href="https://opencollective.com/bigjs#backers" target="_blank"><img src="https://opencollective.com/bigjs/backers.svg?width=890"></a>
|
||||
|
||||
|
||||
## Sponsors
|
||||
|
||||
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bigjs#sponsor)]
|
||||
|
||||
<a href="https://opencollective.com/bigjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/4/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/5/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/6/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/7/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/8/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/bigjs/sponsor/9/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/9/avatar.svg"></a>
|
||||
|
||||
|
||||
|
||||
+941
-941
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
+924
-924
File diff suppressed because it is too large
Load Diff
+61
-29
@@ -1,7 +1,57 @@
|
||||
{
|
||||
"name": "big.js",
|
||||
"_args": [
|
||||
[
|
||||
"big.js@5.2.2",
|
||||
"D:\\韩超勃\\视频会议\\Arbitrate-FrontendH5"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "big.js@5.2.2",
|
||||
"_id": "big.js@5.2.2",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==",
|
||||
"_location": "/big.js",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "big.js@5.2.2",
|
||||
"name": "big.js",
|
||||
"escapedName": "big.js",
|
||||
"rawSpec": "5.2.2",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.2.2"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@vue/cli-service/loader-utils",
|
||||
"/loader-utils",
|
||||
"/vue-style-loader/loader-utils"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
"_spec": "5.2.2",
|
||||
"_where": "D:\\韩超勃\\视频会议\\Arbitrate-FrontendH5",
|
||||
"author": {
|
||||
"name": "Michael Mclaughlin",
|
||||
"email": "M8ch88l@gmail.com"
|
||||
},
|
||||
"browser": "big.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/MikeMcl/big.js/issues"
|
||||
},
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bigjs"
|
||||
},
|
||||
"description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic",
|
||||
"version": "5.2.2",
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"files": [
|
||||
"big.js",
|
||||
"big.mjs",
|
||||
"big.min.js"
|
||||
],
|
||||
"homepage": "https://github.com/MikeMcl/big.js#readme",
|
||||
"keywords": [
|
||||
"arbitrary",
|
||||
"precision",
|
||||
@@ -16,35 +66,17 @@
|
||||
"bigint",
|
||||
"bignum"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "big",
|
||||
"module": "big.mjs",
|
||||
"name": "big.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/MikeMcl/big.js.git"
|
||||
"url": "git+https://github.com/MikeMcl/big.js.git"
|
||||
},
|
||||
"main": "big",
|
||||
"browser": "big.js",
|
||||
"module": "big.mjs",
|
||||
"author": {
|
||||
"name": "Michael Mclaughlin",
|
||||
"email": "M8ch88l@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/MikeMcl/big.js/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "node ./test/every-test.js",
|
||||
"build": "uglifyjs big.js --source-map -c -m -o big.min.js"
|
||||
"build": "uglifyjs big.js --source-map -c -m -o big.min.js",
|
||||
"test": "node ./test/every-test.js"
|
||||
},
|
||||
"files": [
|
||||
"big.js",
|
||||
"big.mjs",
|
||||
"big.min.js"
|
||||
],
|
||||
"collective": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/bigjs"
|
||||
}
|
||||
}
|
||||
"version": "5.2.2"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user