-
Notifications
You must be signed in to change notification settings - Fork 20
/
package.json
45 lines (45 loc) · 11.7 KB
/
package.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
{
"author": {
"name": "Michael Mclaughlin",
"email": "[email protected]"
},
"bugs": {
"url": "https://github.com/MikeMcl/bignumber.js/issues"
},
"dependencies": {},
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic",
"devDependencies": {},
"engines": {
"node": "*"
},
"homepage": "https://github.com/MikeMcl/bignumber.js#readme",
"keywords": [
"arbitrary",
"precision",
"arithmetic",
"big",
"number",
"decimal",
"float",
"biginteger",
"bigdecimal",
"bignumber",
"bigint",
"bignum"
],
"license": "MIT",
"main": "bignumber",
"name": "bignumber.js",
"optionalDependencies": {},
"readme": "![bignumber.js](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/bignumberjs.png)\n\nA JavaScript library for arbitrary-precision decimal and non-decimal arithmetic.\n\n[![Build Status](https://travis-ci.org/MikeMcl/bignumber.js.svg)](https://travis-ci.org/MikeMcl/bignumber.js)\n\n<br />\n\n## Features\n\n - Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal\n - 8 KB minified and gzipped\n - Simple API but full-featured\n - Works with numbers with or without fraction digits in bases from 2 to 64 inclusive\n - Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type\n - Includes a `toFraction` and a correctly-rounded `squareRoot` method\n - Supports cryptographically-secure pseudo-random number generation\n - No dependencies\n - Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only\n - Comprehensive [documentation](http://mikemcl.github.io/bignumber.js/) and test set\n\n![API](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/API.png)\n\nIf a smaller and simpler library is required see [big.js](https://github.com/MikeMcl/big.js/).\nIt's less than half the size but only works with decimal numbers and only has half the methods.\nIt also does not allow `NaN` or `Infinity`, or have the configuration options of this library.\n\nSee also [decimal.js](https://github.com/MikeMcl/decimal.js/), which among other things adds support for non-integer powers, and performs all operations to a specified number of significant digits.\n\n## Load\n\nThe library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*).\n\n```html\n<script src='relative/path/to/bignumber.js'></script>\n```\n\nFor [Node.js](http://nodejs.org) or [io.js](https://iojs.org/en/index.html), the library is available from the [npm](https://npmjs.org/) registry\n\n $ npm install bignumber.js\n\n```javascript\nvar BigNumber = require('bignumber.js');\n```\n\nTo load with AMD loader libraries such as [requireJS](http://requirejs.org/):\n\n```javascript\nrequire(['path/to/bignumber'], function(BigNumber) { \n // Use BigNumber here in local scope. No global BigNumber.\n});\n```\n\n## Use\n\n*In all examples below, `var`, semicolons and `toString` calls are not shown.\nIf a commented-out value is in quotes it means `toString` has been called on the preceding expression.*\n\nThe library exports a single function: `BigNumber`, the constructor of BigNumber instances.\n\nIt accepts a value of type number *(up to 15 significant digits only)*, string or BigNumber object,\n\n```javascript\nx = new BigNumber(123.4567)\ny = BigNumber('123456.7e-3')\nz = new BigNumber(x)\nx.equals(y) && y.equals(z) && x.equals(z) // true\n```\n\n\nand a base from 2 to 64 inclusive can be specified.\n\n```javascript\nx = new BigNumber(1011, 2) // \"11\"\ny = new BigNumber('zz.9', 36) // \"1295.25\"\nz = x.plus(y) // \"1306.25\"\n```\n\nA BigNumber is immutable in the sense that it is not changed by its methods. \n\n```javascript\n0.3 - 0.1 // 0.19999999999999998 \nx = new BigNumber(0.3)\nx.minus(0.1) // \"0.2\"\nx // \"0.3\"\n```\n\nThe methods that return a BigNumber can be chained.\n\n```javascript\nx.dividedBy(y).plus(z).times(9).floor()\nx.times('1.23456780123456789e+9').plus(9876.5432321).dividedBy('4444562598.111772').ceil()\n```\n\nMany method names have a shorter alias.\n\n```javascript\nx.squareRoot().dividedBy(y).toPower(3).equals(x.sqrt().div(y).pow(3)) // true\nx.cmp(y.mod(z).neg()) == 1 && x.comparedTo(y.modulo(z).negated()) == 1 // true\n```\n\nLike JavaScript's number type, there are `toExponential`, `toFixed` and `toPrecision` methods\n\n```javascript\nx = new BigNumber(255.5)\nx.toExponential(5) // \"2.55500e+2\"\nx.toFixed(5) // \"255.50000\"\nx.toPrecision(5) // \"255.50\"\nx.toNumber() // 255.5\n```\n\n and a base can be specified for `toString`.\n\n ```javascript\n x.toString(16) // \"ff.8\"\n ```\n\nThere is also a `toFormat` method which may be useful for internationalisation\n\n```javascript\ny = new BigNumber('1234567.898765')\ny.toFormat(2) // \"1,234,567.90\"\n```\n\nThe maximum number of decimal places of the result of an operation involving division (i.e. a division, square root, base conversion or negative power operation) is set using the `config` method of the `BigNumber` constructor.\n\nThe other arithmetic operations always give the exact result.\n\n```javascript\nBigNumber.config({ DECIMAL_PLACES: 10, ROUNDING_MODE: 4 })\n// Alternatively, BigNumber.config( 10, 4 );\n\nx = new BigNumber(2);\ny = new BigNumber(3);\nz = x.div(y) // \"0.6666666667\"\nz.sqrt() // \"0.8164965809\"\nz.pow(-3) // \"3.3749999995\"\nz.toString(2) // \"0.1010101011\"\nz.times(z) // \"0.44444444448888888889\"\nz.times(z).round(10) // \"0.4444444445\"\n```\n\nThere is a `toFraction` method with an optional *maximum denominator* argument\n\n```javascript\ny = new BigNumber(355)\npi = y.dividedBy(113) // \"3.1415929204\"\npi.toFraction() // [ \"7853982301\", \"2500000000\" ]\npi.toFraction(1000) // [ \"355\", \"113\" ]\n```\n\nand `isNaN` and `isFinite` methods, as `NaN` and `Infinity` are valid `BigNumber` values.\n\n```javascript\nx = new BigNumber(NaN) // \"NaN\"\ny = new BigNumber(Infinity) // \"Infinity\"\nx.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite() // true\n```\n\nThe value of a BigNumber is stored in a decimal floating point format in terms of a coefficient, exponent and sign.\n\n\n```javascript\nx = new BigNumber(-123.456);\nx.c // [ 123, 45600000000000 ] coefficient (i.e. significand)\nx.e // 2 exponent\nx.s // -1 sign\n```\n\n\nMultiple BigNumber constructors can be created, each with their own independent configuration which applies to all BigNumber's created from it.\n\n```javascript\n// Set DECIMAL_PLACES for the original BigNumber constructor\nBigNumber.config({ DECIMAL_PLACES: 10 })\n\n// Create another BigNumber constructor, optionally passing in a configuration object\nBN = BigNumber.another({ DECIMAL_PLACES: 5 })\n\nx = new BigNumber(1)\ny = new BN(1)\n\nx.div(3) // '0.3333333333'\ny.div(3) // '0.33333'\n```\n\nFor futher information see the [API](http://mikemcl.github.io/bignumber.js/) reference in the *doc* directory.\n\n## Test\n\nThe *test* directory contains the test scripts for each method.\n\nThe tests can be run with Node or a browser. For Node use\n\n $ npm test\n\nor\n\n $ node test/every-test\n\nTo test a single method, e.g.\n\n $ node test/toFraction\n\nFor the browser, see *every-test.html* and *single-test.html* in the *test/browser* directory. \n\n*bignumber-vs-number.html* enables some of the methods of bignumber.js to be compared with those of JavaScript's number type. \n\n## Versions\n\nThis is version 2.x.x of the library, for version 1.x.x see the tagged releases or switch to the 'original' branch. The advantages of version 2 are that it is considerably faster for numbers with many digits and that there are a some added methods (see Change Log below). The disadvantages are more lines of code and increased code complexity, and the loss of simplicity in no longer having the coefficient of a BigNumber stored in base 10. The 'original' version will continue to be supported.\n\n## Performance\n\nSee the [README](https://github.com/MikeMcl/bignumber.js/tree/master/perf) in the *perf* directory.\n\n## Build\n\nFor Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed\n\n npm install uglify-js -g\n\nthen\n\n npm run build\n\nwill create *bignumber.min.js*.\n\nA source map will also be created in the root directory.\n\n## Feedback\n\nOpen an issue, or email \n\nMichael\n\n<a href=\"mailto:[email protected]\">[email protected]</a>\n\n## Licence\n\nMIT.\n\nSee [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE).\n\n## Change Log\n\n####2.0.6\n* 31/03/2015\n* Add bower.json. Tweak division after in-depth review.\n\n####2.0.5\n* 25/03/2015\n* Amend README. Remove bitcoin address.\n\n####2.0.4\n* 25/03/2015\n* Critical bugfix #58: division.\n\n####2.0.3\n* 18/02/2015\n* Amend README. Add source map.\n\n####2.0.2\n* 18/02/2015\n* Correct links.\n\n####2.0.1\n* 18/02/2015\n* Add `max`, `min`, `precision`, `random`, `shift`, `toDigits` and `truncated` methods.\n* Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`.\n* Add an `another` method to enable multiple independent constructors to be created.\n* Add support for the base 2, 8 and 16 prefixes `0b`, `0o` and `0x`.\n* Enable a rounding mode to be specified as a second parameter to `toExponential`, `toFixed`, `toFormat` and `toPrecision`.\n* Add a `CRYPTO` configuration property so cryptographically-secure pseudo-random number generation can be specified.\n* Add a `MODULO_MODE` configuration property to enable the rounding mode used by the `modulo` operation to be specified.\n* Add a `POW_PRECISION` configuration property to enable the number of significant digits calculated by the power operation to be limited.\n* Improve code quality.\n* Improve documentation.\n\n####2.0.0\n* 29/12/2014\n* Add `dividedToIntegerBy`, `isInteger` and `toFormat` methods.\n* Remove the following short-forms: `isF`, `isZ`, `toE`, `toF`, `toFr`, `toN`, `toP`, `toS`.\n* Store a BigNumber's coefficient in base 1e14, rather than base 10.\n* Add fast path for integers to BigNumber constructor.\n* Incorporate the library into the online documentation.\n\n####1.5.0\n* 13/11/2014\n* Add `toJSON` and `decimalPlaces` methods.\n\n####1.4.1\n* 08/06/2014\n* Amend README.\n\n####1.4.0\n* 08/05/2014\n* Add `toNumber`.\n\n####1.3.0\n* 08/11/2013\n* Ensure correct rounding of `sqrt` in all, rather than almost all, cases.\n* Maximum radix to 64.\n\n####1.2.1\n* 17/10/2013\n* Sign of zero when x < 0 and x + (-x) = 0.\n\n####1.2.0\n* 19/9/2013\n* Throw Error objects for stack.\n\n####1.1.1\n* 22/8/2013\n* Show original value in constructor error message.\n\n####1.1.0\n* 1/8/2013\n* Allow numbers with trailing radix point. \n\n####1.0.1\n* Bugfix: error messages with incorrect method name\n\n####1.0.0\n* 8/11/2012\n* Initial release\n",
"readmeFilename": "README.md",
"repository": {
"type": "git",
"url": "git+https://github.com/MikeMcl/bignumber.js.git"
},
"scripts": {
"build": "uglifyjs bignumber.js --source-map bignumber.js.map -c -m -o bignumber.min.js --preamble \"/* bignumber.js v2.0.7 https://github.com/MikeMcl/bignumber.js/LICENCE */\"",
"test": "node ./test/every-test.js"
},
"version": "2.0.7"
}