{"id":13457750,"url":"https://github.com/nefe/number-precision","last_synced_at":"2025-05-13T20:21:00.244Z","repository":{"id":37335876,"uuid":"100933681","full_name":"nefe/number-precision","owner":"nefe","description":"🚀1K tiny \u0026 fast lib for doing addition, subtraction, multiplication and division operations precisely","archived":false,"fork":false,"pushed_at":"2024-06-11T02:08:46.000Z","size":333,"stargazers_count":4063,"open_issues_count":13,"forks_count":328,"subscribers_count":57,"default_branch":"master","last_synced_at":"2025-04-28T11:51:28.961Z","etag":null,"topics":["floating-point","number-converter","rounding-error"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nefe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-21T09:03:31.000Z","updated_at":"2025-04-17T07:16:04.000Z","dependencies_parsed_at":"2022-07-12T12:04:56.594Z","dependency_job_id":"d8271e38-ddb4-4b99-9e5a-a0a394c42b8b","html_url":"https://github.com/nefe/number-precision","commit_stats":{"total_commits":63,"total_committers":16,"mean_commits":3.9375,"dds":"0.46031746031746035","last_synced_commit":"6e721680ca116b5b2c3c03db2b36ac57358cd595"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nefe%2Fnumber-precision","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nefe%2Fnumber-precision/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nefe%2Fnumber-precision/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nefe%2Fnumber-precision/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nefe","download_url":"https://codeload.github.com/nefe/number-precision/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020682,"owners_count":22000761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["floating-point","number-converter","rounding-error"],"created_at":"2024-07-31T09:00:35.593Z","updated_at":"2025-05-13T20:21:00.202Z","avatar_url":"https://github.com/nefe.png","language":"TypeScript","readme":"# number-precision [![npm version](https://badge.fury.io/js/number-precision.svg)](http://badge.fury.io/js/number-precision) [![Build Status](https://travis-ci.org/nefe/number-precision.svg)](https://travis-ci.org/nefe/number-precision) [![codecov](https://codecov.io/gh/nefe/number-precision/branch/master/graph/badge.svg)](https://codecov.io/gh/nefe/number-precision)\n\nPerform addition, subtraction, multiplication and division operations precisely using javascript\n\n### Why\n\n```js\n0.1 + 0.2 = 0.30000000000000004\n1.0 - 0.9 = 0.09999999999999998\n0.105.toFixed(2) = 0.1 // not 0.11\n```\n\n### Install\n\n```\nnpm install number-precision --save\n```\n\n### Methods\n\n```js\nNP.strip(num)         // strip a number to nearest right number\nNP.plus(num1, num2, num3, ...)   // addition, num + num2 + num3, two numbers is required at least.\nNP.minus(num1, num2, num3, ...)  // subtraction, num1 - num2 - num3\nNP.times(num1, num2, num3, ...)  // multiplication, num1 * num2 * num3\nNP.divide(num1, num2, num3, ...) // division, num1 / num2 / num3\nNP.round(num, ratio)  // round a number based on ratio\n```\n\n### Usage\n\n```js\nimport NP from 'number-precision'\nNP.strip(0.09999999999999998); // = 0.1\nNP.plus(0.1, 0.2);             // = 0.3, not 0.30000000000000004\nNP.plus(2.3, 2.4);             // = 4.7, not 4.699999999999999\nNP.minus(1.0, 0.9);            // = 0.1, not 0.09999999999999998\nNP.times(3, 0.3);              // = 0.9, not 0.8999999999999999\nNP.times(0.362, 100);          // = 36.2, not 36.199999999999996\nNP.divide(1.21, 1.1);          // = 1.1, not 1.0999999999999999\nNP.round(0.105, 2);            // = 0.11, not 0.1\n```\n\nPS: If you want to get rid of `XXX is beyond boundary when transfer to integer, the results may not be accurate`, use this at the beginning of your app to turn off boundary checking.\n```js\nNP.enableBoundaryChecking(false); // default param is true\n```\n\n### License\nMIT\n","funding_links":[],"categories":["TypeScript","JavaScript","目录"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnefe%2Fnumber-precision","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnefe%2Fnumber-precision","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnefe%2Fnumber-precision/lists"}