{"id":13408048,"url":"https://github.com/sindresorhus/round-to","last_synced_at":"2025-05-16T11:03:47.962Z","repository":{"id":36370715,"uuid":"40675559","full_name":"sindresorhus/round-to","owner":"sindresorhus","description":"Round a number to a specific number of decimal places: 1.234 → 1.2","archived":false,"fork":false,"pushed_at":"2023-08-05T10:34:53.000Z","size":25,"stargazers_count":155,"open_issues_count":2,"forks_count":9,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-11T19:24:23.411Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/sindresorhus.png","metadata":{"funding":{"github":"sindresorhus","open_collective":"sindresorhus","custom":"https://sindresorhus.com/donate"},"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}},"created_at":"2015-08-13T18:37:18.000Z","updated_at":"2024-08-12T10:52:09.000Z","dependencies_parsed_at":"2023-09-24T07:15:28.921Z","dependency_job_id":null,"html_url":"https://github.com/sindresorhus/round-to","commit_stats":{"total_commits":27,"total_committers":8,"mean_commits":3.375,"dds":"0.40740740740740744","last_synced_commit":"6885adef26882b186704e4c8fc414b785947bb92"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fround-to","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fround-to/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fround-to/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fround-to/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/round-to/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471314,"owners_count":22076665,"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":[],"created_at":"2024-07-30T20:00:50.385Z","updated_at":"2025-05-16T11:03:47.944Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# round-to\n\n\u003e Round a number to a specific number of decimal places: `1.234` → `1.2`\n\n## Install\n\n```sh\nnpm install round-to\n```\n\n## Usage\n\n```js\nimport {roundTo, roundToUp, roundToDown} from 'round-to';\n\nroundTo(1.234, 2);\n//=\u003e 1.23\n\nroundToUp(1.234, 2);\n//=\u003e 1.24\n\nroundToDown(1.234, 2);\n//=\u003e 1.23\n```\n\nNumbers are rounded to a specific number of fractional digits. Specifying a negative `precision` will round to any number of places to the left of the decimal.\n\n```js\nroundTo(1234.56, -2);\n//=\u003e 1200\n```\n\nSpecifying an infinite `precision` will assume infinite decimal places.\n\n```js\nroundTo(0.1231782638, Infinity);\n//=\u003e 0.1231782638\n```\n\n## API\n\n### roundTo(number, precision)\n\nRound the decimals with [`Math.round`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round).\n\n### roundToUp(number, precision)\n\nRound up the decimals with [`Math.ceil`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil).\n\n### roundToDown(number, precision)\n\nRound down the decimals with [`Math.floor`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor).\n\n#### number\n\nType: `number`\n\nThe number to adjust.\n\n#### precision\n\nType: `number` *(Integer or infinity)*\n\nThe number of decimal places.\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["Packages","Repository","包","目录","Number","JavaScript"],"sub_categories":["Number","数字","数量","Text"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fround-to","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fround-to","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fround-to/lists"}