{"id":22293536,"url":"https://github.com/gsemac/byte-size","last_synced_at":"2025-06-16T19:33:22.641Z","repository":{"id":112965000,"uuid":"95726621","full_name":"gsemac/byte-size","owner":"gsemac","description":"A class for easily displaying byte quantities in different formats","archived":false,"fork":false,"pushed_at":"2017-08-23T08:13:37.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-06-05T07:02:01.045Z","etag":null,"topics":[],"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/gsemac.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":"2017-06-29T01:34:51.000Z","updated_at":"2020-05-25T20:46:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"6c052e6d-2c20-4013-8c2e-795449e436e3","html_url":"https://github.com/gsemac/byte-size","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gsemac/byte-size","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsemac%2Fbyte-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsemac%2Fbyte-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsemac%2Fbyte-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsemac%2Fbyte-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gsemac","download_url":"https://codeload.github.com/gsemac/byte-size/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gsemac%2Fbyte-size/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260224130,"owners_count":22977349,"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-12-03T17:29:31.655Z","updated_at":"2025-06-16T19:33:22.616Z","avatar_url":"https://github.com/gsemac.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# byte-size\nA class for easily displaying byte quantities in different formats\n\n`ByteSize` (and the accompanying class, `BitSize`) was inspired by Omar's [ByteSize](https://github.com/omar/ByteSize) class for C#.\n\nUse the `ByteSize` class to represent amounts in bytes, kilobytes, megabytes, gigabytes, and so on (up to petabytes):\n\n```cpp\nByteSize bs(1024);\nstd::cout \u003c\u003c bs.Bits(); // outputs 8192\nstd::cout \u003c\u003c bs.Bytes(); // outputs 1024\nstd::cout \u003c\u003c bs.Kilobytes(); // outputs 1\nstd::cout \u003c\u003c bs; // outputs 1.00 KiB\n```\n\nBy default, the binary prefix is used (`1 kilobyte` = `1024 bytes`). The decimal prefix can be used by providing it in the constructor:\n\n```cpp\nByteSize bs(1024, BytePrefix::Decimal); // 1 kilobyte = 1000 bytes\nstd::cout \u003c\u003c bs; // outputs 1.02 kB\n```\n\nThe `BitSize` class works similarly, but is used to represent amounts in kilobits, megabits, gigabits, and so on (up to petabits):\n\n```cpp\nBitSize bs_binary(1024);\nBitSize bs_decimal(1024, BytePrefix::Decimal);\nstd::cout \u003c\u003c bs_binary; // outputs 8.00 Kibit\nstd::cout \u003c\u003c bs_decimal; // outputs 8.19 kbit\n```\n\nYou can also create an instance of either class from a `string`, and the correct prefix will be deduced:\n\n```cpp\nByteSize bs = ByteSize::Parse(\"1kB\");\nstd::cout \u003c\u003c bs.ToString(1); // outputs 1.0 kB\n```\n\nVarious methods exist to create an instance of either class from a given unit:\n\n```cpp\nByteSize bs = ByteSize::FromMegabytes(0.5);\nstd::cout \u003c\u003c bs; // outputs 512 KiB\n```\n\n#### License\n\nReleased under [MIT License](https://github.com/gsemac/byte-size/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsemac%2Fbyte-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgsemac%2Fbyte-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgsemac%2Fbyte-size/lists"}