{"id":19375987,"url":"https://github.com/ftonato/metic","last_synced_at":"2025-04-23T18:32:58.094Z","repository":{"id":41131336,"uuid":"508300308","full_name":"ftonato/metic","owner":"ftonato","description":"Easy math decimals for JS","archived":false,"fork":false,"pushed_at":"2022-06-28T19:19:37.000Z","size":59,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T08:16:41.444Z","etag":null,"topics":["arithmetics","decimals","math","mathmatics","number"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/metic","language":"TypeScript","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/ftonato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["ftonato"]}},"created_at":"2022-06-28T12:58:51.000Z","updated_at":"2022-07-03T10:06:51.000Z","dependencies_parsed_at":"2022-09-07T20:21:08.925Z","dependency_job_id":null,"html_url":"https://github.com/ftonato/metic","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fmetic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fmetic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fmetic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ftonato%2Fmetic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ftonato","download_url":"https://codeload.github.com/ftonato/metic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250490537,"owners_count":21439161,"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":["arithmetics","decimals","math","mathmatics","number"],"created_at":"2024-11-10T08:41:01.098Z","updated_at":"2025-04-23T18:32:57.826Z","avatar_url":"https://github.com/ftonato.png","language":"TypeScript","funding_links":["https://github.com/sponsors/ftonato"],"categories":[],"sub_categories":[],"readme":"# Metic\n\n\u003e Easy math decimals for JS\n\u003e  \n\u003e `metic.add(0.1, 0.2, 2) === 0.3`\n\nThis is a simple and useful package to help you on arithmetics.\n\n----\n## Context\n\nIf you've ever tried to sum decimal numbers in JavaScript, you were definitely surprised...\n\nWe know that `0.1 + 0.1` is, as you expect, `0.2`.\n\nBut sometimes you get some unexpected result.\n\nAs for `0.1 + 0.2`.\n\nThe result is not `0.3` as you would expect, but it is `0.30000000000000004`.\n\nYes, the first time I was surprised too. However, if you search further to find out what happens via these links:\n\n- [Why 0.1 + 0.2 == 0.3 is false in JS?](https://gauravkk22.medium.com/why-0-1-0-2-0-3-is-false-in-js-mystery-unsolved-with-solution-4f7db2755f18)\n- [Why 0.1 + 0.2 ≠ 0.3 in JavaScript](https://javascript.plainenglish.io/why-0-1-0-2-0-3-in-javascript-d7e218224a72)\n\n----\n## Install\n\n```sh\nnpm install metic\n```\n\n### Usage\n```javascript\nimport metic from 'metic'\n// import {metic} from 'metic'\n\nmetic.add(0.1, 0.2) // =\u003e 0.3\n```\n\nYou can also use as many decimals places as you like and ensure the value will be as close to what you expect.\n\n```javascript\nimport metic from 'metic'\n// import {metic} from 'metic'\n\n/**\n * Calculate the sum of two decimals properly.\n * @param {number} a - First value to be considered in the sum.\n * @param {number} b - Second value to be considered in the sum.\n * @param {number} positions - Number of decimals we expect as our result.\n */\nmetic.add(0.1, 0.222, 3) // =\u003e 0.322\n```\n\n## LICENSE\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftonato%2Fmetic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fftonato%2Fmetic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fftonato%2Fmetic/lists"}