{"_id":"@1nd/decimal.js","_rev":"1-8be325800a05e8287959766c85adda4d","name":"@1nd/decimal.js","dist-tags":{"latest":"11.0.0-beta.1"},"versions":{"11.0.0-beta.1":{"name":"@1nd/decimal.js","description":"An arbitrary-precision Decimal type for JavaScript.","version":"11.0.0-beta.1","keywords":["arbitrary","precision","arithmetic","big","number","decimal","float","biginteger","bigdecimal","bignumber","bigint","bignum"],"repository":{"type":"git","url":"git+https://github.com/%401nd/decimal.js.git"},"main":"decimal","browser":"decimal.js","author":{"name":"Michael Mclaughlin","email":"M8ch88l@gmail.com"},"license":"MIT","scripts":{"test":"node ./test/test.js","build":"uglifyjs decimal.js --source-map url=decimal.min.js.map -c -m -o decimal.min.js","prepublishOnly":"pnpm run build && pnpm test"},"devDependencies":{"uglify-js":"^3.12.4"},"types":"decimal.d.ts","gitHead":"be7d6b05ab534cf1eda0a1d0a2558e8f049583fe","bugs":{"url":"https://github.com/%401nd/decimal.js/issues"},"homepage":"https://github.com/%401nd/decimal.js#readme","_id":"@1nd/decimal.js@11.0.0-beta.1","_nodeVersion":"12.18.2","_npmVersion":"6.14.5","dist":{"integrity":"sha512-5OH2/1OlKiGWFp2E62mK7qcpFd7QZqK+sNPMFLZ/DNm4Ln2EtBkS0XlH5/OnZ6Cck5gwMoAKPoTk1ao0D0O0Ow==","shasum":"023d70c8de61107bb61f6e1672b567e284640e46","tarball":"https://registry.npmjs.org/@1nd/decimal.js/-/decimal.js-11.0.0-beta.1.tgz","fileCount":9,"unpackedSize":247912,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgBUfmCRA9TVsSAnZWagAA/vkP/2+EwOOjwosy0EfcYQ4p\nlkvDc2FwCYsMjspS2oS5OkIfbUlOahQ+i3pnPGrLsTtfk85jXszRbaoVYSOh\n/XT/+TnBsvOcUC//N308bGi89TID/voztdVvC6pII9ekbVRrbi+cydgTLtsr\naVmbYUnzjr5sGAiAxgpb9E2AB3dD21x2wuVoh93O7j+n6zHyQWakTpkJTe/B\n/6q8dDP2hzkUFIZvaJj28zjzbIt8ejYHK3RyvSCfx1D0Q/pbj1+jL4sEmvnS\nGH7hzxu6g2h/Hb9zsEEJcvX/DXt+8s9WXbExnpmK4+b32snbd/1kLM4m3FOC\n3zWUsV1DeJ4s3IQX5j2GX3Skxzk3bLrU0QjKo9xE6Sf90u0mG3F0bi6Z8Flf\n4UlF7XvPWzKon4r1zZMbpFhGS/JpYq4trrVC13o4/wuUT+YyQ8t1Wv2+FEGS\nj8DWu9OQCagqxDJb72x4kAOhF9xFYas+Ue8oxB5120CtSgELw7gQoX7BquhK\nz+S5xVmwRiGkVVH+a4LlrSdZKHTOTI84Q863s+zrd+zK2hHa3TQTjQb0JmPq\n0WiPppHGsTHNm8+Bt4ZCa7LHRxxxeb8CoxDcwrOWe33kacIiE07DsvqnNCpk\n6tZl8uRwzvaOMlBCAZEGML9lwghvVZ/9KIju8jyWznbyXe0j1ta4dKVbSR+D\ncmo0\r\n=DfZO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDCgLsJzOgreOHRuDmjU+obUeZANqip7IjhxLuj1v7HPAiEAzUZmrkTdF7hBJXnQbXEx3ECECNo7kRCOvgGNVkSOKLE="}]},"_npmUser":{"name":"1nd","email":"pradhana.indra@gmail.com"},"directories":{},"maintainers":[{"name":"1nd","email":"pradhana.indra@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/decimal.js_11.0.0-beta.1_1610958818937_0.04845642388633453"},"_hasShrinkwrap":false}},"time":{"created":"2021-01-18T08:33:38.898Z","11.0.0-beta.1":"2021-01-18T08:33:39.133Z","modified":"2022-04-04T10:33:50.076Z"},"maintainers":[{"name":"1nd","email":"pradhana.indra@gmail.com"}],"description":"An arbitrary-precision Decimal type for JavaScript.","homepage":"https://github.com/%401nd/decimal.js#readme","keywords":["arbitrary","precision","arithmetic","big","number","decimal","float","biginteger","bigdecimal","bignumber","bigint","bignum"],"repository":{"type":"git","url":"git+https://github.com/%401nd/decimal.js.git"},"author":{"name":"Michael Mclaughlin","email":"M8ch88l@gmail.com"},"bugs":{"url":"https://github.com/%401nd/decimal.js/issues"},"license":"MIT","readme":"![decimal.js](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/decimaljs.png)\n\nAn arbitrary-precision Decimal type for JavaScript.\n\n[![npm version](https://img.shields.io/npm/v/decimal.js.svg)](https://www.npmjs.com/package/decimal.js)\n[![npm downloads](https://img.shields.io/npm/dw/decimal.js)](https://www.npmjs.com/package/decimal.js)\n[![Build Status](https://travis-ci.org/MikeMcl/decimal.js.svg)](https://travis-ci.org/MikeMcl/decimal.js)\n[![CDNJS](https://img.shields.io/cdnjs/v/decimal.js.svg)](https://cdnjs.com/libraries/decimal.js)\n\n<br>\n\n## Features\n\n  - Integers and floats\n  - Simple but full-featured API\n  - Replicates many of the methods of JavaScript's `Number.prototype` and `Math` objects\n  - Also handles hexadecimal, binary and octal values\n  - Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal\n  - No dependencies\n  - Wide platform compatibility: uses JavaScript 1.5 (ECMAScript 3) features only\n  - Comprehensive [documentation](http://mikemcl.github.io/decimal.js/) and test set\n  - Includes a TypeScript declaration file: *decimal.d.ts*\n\n![API](https://raw.githubusercontent.com/MikeMcl/decimal.js/gh-pages/API.png)\n\nThe library is similar to [bignumber.js](https://github.com/MikeMcl/bignumber.js/), but here\nprecision is specified in terms of significant digits rather than decimal places, and all\ncalculations are rounded to the precision (similar to Python's decimal module) rather than just\nthose involving division.\n\nThis library also adds the trigonometric functions, among others, and supports non-integer powers,\nwhich makes it a significantly larger library than *bignumber.js* and the even smaller\n[big.js](https://github.com/MikeMcl/big.js/).\n\nFor a lighter version of this library without the trigonometric functions see [decimal.js-light](https://github.com/MikeMcl/decimal.js-light/).\n\n## Load\n\nThe library is the single JavaScript file *decimal.js* or ES module *decimal.mjs*.\n\nBrowser:\n\n```html\n<script src='path/to/decimal.js'></script>\n```\n\n```html\n<script type=\"module\">\nimport Decimal from './path/to/decimal.mjs';\n...\n</script>\n```\n\n[Node.js](http://nodejs.org):\n\n```bash\n$ npm install decimal.js\n```\n\n```js\nvar Decimal = require('decimal.js');\n```\n\nES module:\n\n```js\n//import Decimal from 'decimal.js';\nimport {Decimal} from 'decimal.js';\n```\n\nAMD loader libraries such as [requireJS](http://requirejs.org/):\n\n```js\nrequire(['decimal'], function(Decimal) {\n    // Use Decimal here in local scope. No global Decimal.\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 object, `Decimal`, the constructor of Decimal instances.\n\nIt accepts a value of type number, string or Decimal.\n\n```js\nx = new Decimal(123.4567)\ny = new Decimal('123456.7e-3')\nz = new Decimal(x)\nx.equals(y) && y.equals(z) && x.equals(z)        // true\n```\n\nA value can also be in binary, hexadecimal or octal if the appropriate prefix is included.\n\n```js\nx = new Decimal('0xff.f')            // '255.9375'\ny = new Decimal('0b10101100')        // '172'\nz = x.plus(y)                        // '427.9375'\n\nz.toBinary()                         // '0b110101011.1111'\nz.toBinary(13)                       // '0b1.101010111111p+8'\n```\n\nUsing binary exponential notation to create a Decimal with the value of `Number.MAX_VALUE`:\n\n```js\nx = new Decimal('0b1.1111111111111111111111111111111111111111111111111111p+1023')\n```\n\nA Decimal is immutable in the sense that it is not changed by its methods.\n\n```js\n0.3 - 0.1                     // 0.19999999999999998\nx = new Decimal(0.3)\nx.minus(0.1)                  // '0.2'\nx                             // '0.3'\n```\n\nThe methods that return a Decimal can be chained.\n\n```js\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```js\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```js\nx = new Decimal(255.5)\nx.toExponential(5)              // '2.55500e+2'\nx.toFixed(5)                    // '255.50000'\nx.toPrecision(5)                // '255.50'\n```\n\nand almost all of the methods of JavaScript's Math object are also replicated.\n\n```js\nDecimal.sqrt('6.98372465832e+9823')      // '8.3568682281821340204e+4911'\nDecimal.pow(2, 0.0979843)                // '1.0702770511687781839'\n```\n\nThere are `isNaN` and `isFinite` methods, as `NaN` and `Infinity` are valid `Decimal` values,\n\n```js\nx = new Decimal(NaN)                                           // 'NaN'\ny = new Decimal(Infinity)                                      // 'Infinity'\nx.isNaN() && !y.isNaN() && !x.isFinite() && !y.isFinite()      // true\n```\n\nand a `toFraction` method with an optional *maximum denominator* argument\n\n```js\nz = new Decimal(355)\npi = z.dividedBy(113)        // '3.1415929204'\npi.toFraction()              // [ '7853982301', '2500000000' ]\npi.toFraction(1000)          // [ '355', '113' ]\n```\n\nAll calculations are rounded according to the number of significant digits and rounding mode\nspecified by the `precision` and `rounding` properties of the Decimal constructor.\n\nFor advanced usage, multiple Decimal constructors can be created, each with their own independent configuration which\napplies to all Decimal numbers created from it.\n\n```js\n// Set the precision and rounding of the default Decimal constructor\nDecimal.set({ precision: 5, rounding: 4 })\n\n// Create another Decimal constructor, optionally passing in a configuration object\nDecimal9 = Decimal.clone({ precision: 9, rounding: 1 })\n\nx = new Decimal(5)\ny = new Decimal9(5)\n\nx.div(3)                           // '1.6667'\ny.div(3)                           // '1.66666666'\n```\n\nThe value of a Decimal is stored in a floating point format in terms of its digits, exponent and sign.\n\n```js\nx = new Decimal(-12345.67);\nx.d                            // [ 12345, 6700000 ]    digits (base 10000000)\nx.e                            // 4                     exponent (base 10)\nx.s                            // -1                    sign\n```\n\nFor further information see the [API](http://mikemcl.github.io/decimal.js/) reference in the *doc* directory.\n\n## Test\n\nThe library can be tested using Node.js or a browser.\n\nThe *test* directory contains the file *test.js* which runs all the tests when executed by Node,\nand the file *test.html* which runs all the tests when opened in a browser.\n\nTo run all the tests, from a command-line at the root directory using npm\n\n```bash\n$ npm test\n```\n\nor at the *test* directory using Node\n\n```bash\n$ node test\n```\n\nEach separate test module can also be executed individually, for example, at the *test/modules* directory\n\n```bash\n$ node toFraction\n```\n\n## Build\n\nFor Node, if [uglify-js](https://github.com/mishoo/UglifyJS2) is installed\n\n```bash\nnpm install uglify-js -g\n```\n\nthen\n\n```bash\nnpm run build\n```\n\nwill create *decimal.min.js*, and a source map will also be added to the *doc* directory.\n\n## Licence\n\nMIT.\n\nSee *LICENCE.md*\n","readmeFilename":"README.md"}