{"_id":"decimal","_rev":"11-a198059fb82bbe243f7571d566673b05","name":"decimal","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.2":{"name":"decimal","version":"0.0.2","keywords":["arithmetic","decimal","float","calculation"],"author":{"name":"Samori Gorse","email":"samorigorse@gmail.com"},"_id":"decimal@0.0.2","maintainers":[{"name":"shinuza","email":"samorigorse@gmail.com"}],"dist":{"shasum":"1943ec52368a0fdf7a372c2c10cf1fcbc91b93e3","tarball":"https://registry.npmjs.org/decimal/-/decimal-0.0.2.tgz","integrity":"sha512-puX1+D5GlpXYH0kDejnu8F2jsGLKRePc7eOznNjqMbA2otl7AzvubrvvZVmOvRCHhsqeAPKNcAxHHbevsH/1qg==","signatures":[{"sig":"MEUCIQCshT0okJmqaW7Id+f32Y68sZVkW6vmFFfkDT6B4fPL1AIgbY8PWfNeNbFS+7O+LlHRluCNWHk1BEvUBEStO3HvLi4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./lib/decimal","engines":{"node":"0.4.x"},"_npmUser":{"name":"shinuza","email":"samorigorse@gmail.com"},"repository":{"url":"git://github.com/shinuza/decimal-js.git","type":"git"},"_npmVersion":"1.0.106","description":"Simple decimal arithmetic for the browser and node.js!","_nodeVersion":"v0.6.6","dependencies":{},"_defaultsLoaded":true,"devDependencies":{},"_engineSupported":false,"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"time":{"created":"2011-12-25T15:08:49.842Z","modified":"2026-02-14T10:19:00.891Z","0.0.2":"2011-12-25T15:08:51.819Z"},"author":{"name":"Samori Gorse","email":"samorigorse@gmail.com"},"repository":{"url":"git://github.com/shinuza/decimal-js.git","type":"git"},"description":"Simple decimal arithmetic for the browser and node.js!","keywords":["arithmetic","decimal","float","calculation"],"maintainers":[{"name":"shinuza","email":"samorigorse@gmail.com"}],"readme":"Decimal\n======\n\nSimple decimal arithmetic for the browser *and* node.js!\n\n\nWhy?\n=======\n\n    Why don’t my numbers, like 0.1 + 0.2 add up to a nice round 0.3,\n    and instead I get a weird result like 0.30000000000000004?\n\n    Because internally, computers use a format (binary floating-point)\n    that cannot accurately represent a number like 0.1, 0.2 or 0.3 at all.\n\nSource : http://floating-point-gui.de/\n\nI wrote this because I needed to do simple computation in the browser\nand I couldn't find a lightweight library to do it.\n\nHow to use?\n===========\n\n\nIn the browser\n--------------\n\n    <script src=\"lib/decimal.js\"></script>\n\nIn node\n-------\n\n    npm install decimal\n\nthen in your program\n\n    var Decimal = require('decimal');\n\n\nExamples\n=======\n\n    >>> 1.1 + 2.2\n    3.3000000000000003\n\n    >>> Decimal('1.1').add('2.2').toNumber()\n    3.3\n\n    >>> 4.01 * 2.01\n    8.060099999999998\n\n    >>> Decimal('4.01').mul('2.01').toNumber()\n    8.0601\n\n    >>> Decimal.mul('4.01', '2.01').toNumber()\n    8.0601\n\n\nCan I help?\n===========\n\nOf course you can, I suck at math, and this implementation is very naive.\nIf you are a math Guru and you see something wrong or a\nway to simplify things you can send in a pull request.\n\n\nMethods\n=======\n\nDecimal(n)\n------------------\n\nCreate a new `Decimal` from `n`. `n` can be a string, integer, or\nanother `Decimal`.\n\n.toString()\n------------------\n\nReturns the `Decimal` instance as a string.\n\n.toNumber()\n-----------\n\nTurn a `Decimal` into a `Number`.\n\n.add(n)\n-------\n\nReturn a new `Decimal` containing the instance value plus `n`.\n\n.sub(n)\n-------\n\nReturn a new `Decimal` containing the instance value minus `n`.\n\n.mul(n)\n-------\n\nReturn a new `Decimal` containing the instance value multiplied by `n`.\n\n.div(n)\n-------\n\nReturn a new `Decimal` containing the instance value integrally divided by `n`.\n\n","users":{"pengzhao":true,"johanliebert":true}}