{"id":16178356,"url":"https://github.com/munrocket/fixed-point","last_synced_at":"2026-02-25T02:31:54.165Z","repository":{"id":95974499,"uuid":"413730982","full_name":"munrocket/fixed-point","owner":"munrocket","description":"🗿 Fixed point arithmetic with BigInt. Minimalistic library for money calculation.","archived":false,"fork":false,"pushed_at":"2021-11-02T22:54:07.000Z","size":48,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-09T18:05:48.939Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/munrocket.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2021-10-05T08:17:52.000Z","updated_at":"2023-09-14T14:22:48.000Z","dependencies_parsed_at":"2023-04-06T03:02:31.992Z","dependency_job_id":null,"html_url":"https://github.com/munrocket/fixed-point","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/munrocket/fixed-point","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munrocket%2Ffixed-point","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munrocket%2Ffixed-point/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munrocket%2Ffixed-point/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munrocket%2Ffixed-point/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/munrocket","download_url":"https://codeload.github.com/munrocket/fixed-point/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/munrocket%2Ffixed-point/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29809086,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T22:43:48.403Z","status":"online","status_checked_at":"2026-02-25T02:00:07.329Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-10T05:13:35.298Z","updated_at":"2026-02-25T02:31:54.150Z","avatar_url":"https://github.com/munrocket.png","language":"JavaScript","readme":"# 🗿 fixed-point\nFixed point arithmetic with BigInt. Minimalistic library for money or scientific calculations with known precision.\n\n### Examples\n\nInstall package `npm install fixed-point` or include minified script on page.\n\n```js\nimport { FixedPoint } from 'fixed-point';\n\n// Simple example: 0.3 - 0.2 = 0.1\nconsole.log(new FixedPoint(0.3).sub(0.2).toString());\n\n// Price with 30% discount, rounding benefiting the customer\nFixedPoint.setRounding('floor');\nconsole.log(new FixedPoint('99.95').mul(0.70).toFixed())\n\n// Bitcoin fee with banker rounding: 1.0 BTC - 0.00005 BTC = 0.99995000 BTC  \nFixedPoint.setRounding('even');\nFixedPoint.setPrecision(8);\nconsole.log(new FixedPoint('1').sub('0.00005').toFixed() + ' BTC');\n\n// Rounding mode for fast calculations\nFixedPoint.setRounding('trunc');\nFixedPoint.setPrecision(15);\nconsole.log(new FixedPoint('3.14159265358979').mul('2'));\n```\n\n### API\n\n* `new FixedPoint(string)` - constructor from String\n* `new FixedPoint(number)` - constructor from Number\n* `a.toString()` - conversion to String\n* `a.toFixed()` - conversion to String\n* `FixedPoint.setPrecision(number)` - set precision (2 decimal places is default)\n* `FixedPoint.setRounding(string)` - set rounding ('trunc'|'floor'|'ceil'|'even'), 'even' is default\n* `a.add(b)` - addition (exact)\n* `a.sub(b)` - subtraction (exact)\n* `a.mul(b)` - multiplication (rounded)\n* `a.div(b)` - division (rounded)\n* `a.eq(b)` - `a == b`\n* `a.ne(b)` - `a != b`\n* `a.gt(b)` - `a \u003e b`\n* `a.ge(b)` - `a \u003e= b`\n* `a.lt(b)` - `a \u003c b`\n* `a.le(b)` - `a \u003c= b`\n\n### 2do\n- [x] constructors, toString/toFixed\n- [x] operations: +|-|*|/\n- [x] 4 rounding modes from IEEE 754-1985: RN, RZ, RU, RD\n- [x] testing rounding modes with table\n- [x] get feedback\n- [x] add benchmark\n- [ ] add precision conversion: x.xxxxxxxx BTC in xx.xx $\n- [ ] add build with BigInt polyfill\n\n### Motivation\nThis library was inspired by conversion in decimal-proposal, also by Yaffle PR in extra-bigint\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunrocket%2Ffixed-point","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmunrocket%2Ffixed-point","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmunrocket%2Ffixed-point/lists"}