{"id":48955108,"url":"https://github.com/ajakhotia/units","last_synced_at":"2026-04-17T23:17:06.294Z","repository":{"id":49947866,"uuid":"138821031","full_name":"ajakhotia/units","owner":"ajakhotia","description":"A type-safe representation of units with zero-run-time overhead. This library decouples the physical dimensions from the units themselves there by allowing to inter-convert between different systems such as SI and Imperial. The system allows for non-integer rational powers of physical dimensions as well(eg: L^2.5)","archived":false,"fork":false,"pushed_at":"2025-08-06T11:25:19.000Z","size":94,"stargazers_count":8,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-06T12:32:07.563Z","etag":null,"topics":["affine","affine-units","cpp14","dimensional-analysis","header-only","mit-license","physical-units","type-safe-units","units","zero-runtime-overhead"],"latest_commit_sha":null,"homepage":"","language":"C++","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/ajakhotia.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}},"created_at":"2018-06-27T02:46:08.000Z","updated_at":"2025-08-06T11:20:44.000Z","dependencies_parsed_at":"2022-08-30T11:20:14.218Z","dependency_job_id":null,"html_url":"https://github.com/ajakhotia/units","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/ajakhotia/units","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajakhotia%2Funits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajakhotia%2Funits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajakhotia%2Funits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajakhotia%2Funits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajakhotia","download_url":"https://codeload.github.com/ajakhotia/units/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajakhotia%2Funits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31949576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-17T17:29:20.459Z","status":"ssl_error","status_checked_at":"2026-04-17T17:28:47.801Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["affine","affine-units","cpp14","dimensional-analysis","header-only","mit-license","physical-units","type-safe-units","units","zero-runtime-overhead"],"created_at":"2026-04-17T23:17:05.653Z","updated_at":"2026-04-17T23:17:06.286Z","avatar_url":"https://github.com/ajakhotia.png","language":"C++","readme":"![units workflow name](https://github.com/ajakhotia/units/workflows/Master%20Unit%20Tests/badge.svg)\n\n# Units\nA type-safe representation of physical units with zero run-time overhead. The type safety is achieved by statically keeping track of the physical dimensions and the scale for the each type. The dimensions and scales are tracked using std::ratio, hence, the system is capable of representing non-integer powers of physical dimensions. Multiplicative operators are designed to handle type conversions correctly. Additive operators are defined only for physical quantities that have matching physical dimensions. The scale conversions are handled implicitly by the system.\n\n## Examples\n\n```\nusing namespace units;\n\nconst Metres m1(5.0);     // Has dimensions of (L^(1,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (1/1)\nconst Inches i1(2.0);     // Has dimensions of (L^(1,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (127/5000)\n\nconst auto l1 = m1 + i1;  // Has dimensions of (L^(1,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (1/1)\n                          // Inches will be appropriately converted into Metres.\n\nconst auto l2 = i1 + m1;  // Has dimensions of (L^(1,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (127/5000)\n                          // Metres will be appropriately converted into Inches.\n\nconst auto a1 = m1 * m1;  // Has dimensions of (L^(2,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (1/1)\nconst auto a2 = m1 * i1;  // Has dimensions of (L^(2,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (127/5000)\nconst auto a3 = i1 * i1;  // Has dimensions of (L^(2,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (16129/25000000)\n\n//m1 + a1;                // Illeagal operation. Won't compile. Cannot add length to area.\na2 + a3;                  // Legal operation. Both quantities have have same physical dimensions. Appropriate conversions will be done automatically.\na2 * i1                   // Has dimensions of (L^(3,0), M^(0,0), T^(0,0), I^(0,0), K^(0,0), N^(0,0), J^(0,0)) and scale (16129/25000000)\n\n```\n\nNote: The above examples show uses only for lengths, but the same concept is valid across all combinations of the 7 physical quantities. In short, all units can be multiplies or divided. Only the units that have same physical dimensions can be added, subtracted or be logically compared(==, !=, \u003c, \u003c=, \u003e, \u003e=).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajakhotia%2Funits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajakhotia%2Funits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajakhotia%2Funits/lists"}