{"id":23508763,"url":"https://github.com/lovasko/libits","last_synced_at":"2025-09-07T20:46:14.512Z","repository":{"id":34613241,"uuid":"38561917","full_name":"lovasko/libits","owner":"lovasko","description":"C89/POSIX Int -\u003e String Conversion Library","archived":false,"fork":false,"pushed_at":"2015-07-24T13:30:51.000Z","size":132,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-13T15:57:01.845Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lovasko.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-05T08:17:40.000Z","updated_at":"2015-07-15T11:53:26.000Z","dependencies_parsed_at":"2022-08-17T21:05:12.410Z","dependency_job_id":null,"html_url":"https://github.com/lovasko/libits","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/lovasko/libits","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lovasko","download_url":"https://codeload.github.com/lovasko/libits/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lovasko%2Flibits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274094678,"owners_count":25221424,"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","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"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-12-25T11:32:02.655Z","updated_at":"2025-09-07T20:46:14.475Z","avatar_url":"https://github.com/lovasko.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libits\nC89/POSIX-compliant conversion library from integers to strings that supports\nvarious signed and unsigned integer number bases and bit-widths.\n\n## Example\n```C\n#include \u003cstdlib.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cits.h\u003e\n\nint\nmain(void)\n{\n\tint a;\n\tchar* a_str;\n\n\ta = -123;\n\ta_str = its(\u0026a, ITS_SIZE_INT, ITS_SIGNED, ITS_BASE_HEX | ITS_PREFIX);\n\tprintf(\"%s\\n\", a_str);\n\t\n\tfree(a_str);\n\treturn EXIT_SUCCESS;\n}\n```\n\nCompile \u0026 run:\n```\n$ clang example.c -lits\n$ ./a.out\n-0x7b\n```\n\n## Q\u0026A\n#### How is this better than `(asn)printf`?\n * Binary base\n * Signed hexadecimal and octal numbers up to `(U)INT_MAX`\n * Correct handling of arbitrary bit-sized integers\n\n#### How is this worse than `(asn)printf`?\n * It is a (yet another) dependency\n * Not standard\n * More verbose usage\n\n#### How do I get all the bonus features of `printf` (like fixed width printing or alignment).\nFor such features, the `printf` alternative is the solution. But instead of\n`%lld` or any related format, use the `%s` format with value of a `its` call.\n\n## Build\n```\n$ ninja\n```\n\n## Supported platforms \u0026 standards \nThe library is working quite heavily with the two-complement format of signed\nintegers, which is one of the three signed number representations allowed by\nthe C89 standard and the only representation allowed in the POSIX family of\nstandards.\n\n * FreeBSD 10.0 with Clang 3.3\n\nIf a platform does not appear to be in the previous list, it does not mean that\n`libits` will not work in such environment. It only means that nobody tested\nit - you are encouraged to do so and report either success or failure.\n\n## License\n2-clause BSD license. For more information please consult the\n[LICENSE](LICENSE.md) file. In the case that you need a different license, feel\nfree to contact me.\n\n## Author\nDaniel Lovasko lovasko@freebsd.org\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Flibits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flovasko%2Flibits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flovasko%2Flibits/lists"}