{"id":18001639,"url":"https://github.com/rigtorp/charconv","last_synced_at":"2025-03-26T08:30:53.309Z","repository":{"id":137958181,"uuid":"115455895","full_name":"rigtorp/CharConv","owner":"rigtorp","description":"Fast integer to string and string to integer conversion functions","archived":false,"fork":false,"pushed_at":"2023-09-25T06:57:41.000Z","size":310,"stargazers_count":21,"open_issues_count":0,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-24T00:31:28.584Z","etag":null,"topics":["atoi","cpp17","integer-conversion","itoa","string-conversion"],"latest_commit_sha":null,"homepage":null,"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/rigtorp.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-12-26T21:24:44.000Z","updated_at":"2025-01-21T01:20:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"3590c53d-b1b1-4c9b-aeea-f33ea208e636","html_url":"https://github.com/rigtorp/CharConv","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/rigtorp%2FCharConv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigtorp%2FCharConv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigtorp%2FCharConv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rigtorp%2FCharConv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rigtorp","download_url":"https://codeload.github.com/rigtorp/CharConv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245618579,"owners_count":20645026,"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":["atoi","cpp17","integer-conversion","itoa","string-conversion"],"created_at":"2024-10-29T23:18:17.513Z","updated_at":"2025-03-26T08:30:52.750Z","avatar_url":"https://github.com/rigtorp.png","language":"C++","readme":"# CharConv.h\n\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/rigtorp/HashMap/master/LICENSE)\n\nFast integer to string and string to integer conversion functions.\n\n## Usage\n\n`CharConv.h` exposes two functions: `to_chars` and `from_chars`. The API is\nsimilar, but not identical to that of\n[to_chars](http://en.cppreference.com/w/cpp/utility/to_chars) and\n[from_chars](http://en.cppreference.com/w/cpp/utility/from_chars) in the C++17\nstandard.\n\n- `to_chars_result to_chars(char *first, char *last, int32_t value) noexcept`\n- `to_chars_result to_chars(char *first, char *last, uint32_t value) noexcept`\n- `to_chars_result to_chars(char *first, char *last, int64_t value) noexcept`\n- `to_chars_result to_chars(char *first, char *last, uint64_t value) noexcept`\n\n  Converts `value` into characters in base 10.  \n\n- `from_chars_result from_chars(const char *first, const char *last, int32_t \u0026value) noexcept`\n- `from_chars_result from_chars(const char *first, const char *last, uint32_t \u0026value) noexcept`\n- `from_chars_result from_chars(const char *first, const char *last, int64_t \u0026value) noexcept`\n- `from_chars_result from_chars(const char *first, const char *last, uint64_t \u0026value) noexcept`\n\n  Converts the character sequence `[first, last]` representing\n  a base 10 number to an integer value.\n\n## Example\n\n```cpp\nusing namespace rigtorp;\n\nstd::array\u003cchar, 32\u003e buf = {};\nto_chars(buf.begin(), buf.end(), 123));\nstd::cout \u003c\u003c buf.data();\n\nint result;\nfrom_chars(buf.begin(), buf.end(), result);\nstd::cout \u003c\u003c result; \n```\n\n## Benchmark\n\nRunning on Intel(R) Xeon(R) CPU E5-2620 v4 @ 2.10GHz:\n\n```\n2017-12-26 15:08:09\nRun on (32 X 3000 MHz CPU s)\nCPU Caches:\n  L1 Data 32K (x16)\n  L1 Instruction 32K (x16)\n  L2 Unified 256K (x16)\n  L3 Unified 20480K (x2)\n-----------------------------------------------------------------\nBenchmark                          Time           CPU Iterations\n-----------------------------------------------------------------\nBM_sprintf/1                      73 ns         73 ns    9625985\nBM_sprintf/2                      75 ns         75 ns    9284410\nBM_sprintf/3                      77 ns         77 ns    9135939\nBM_sprintf/4                      79 ns         79 ns    8868328\nBM_sprintf/5                      80 ns         80 ns    8716034\nBM_sprintf/6                      82 ns         82 ns    8561608\nBM_sprintf/7                      83 ns         83 ns    8426476\nBM_sprintf/8                      85 ns         85 ns    8219398\nBM_sprintf/9                      87 ns         87 ns    8016940\nBM_to_string/1                    76 ns         76 ns    9159664\nBM_to_string/2                    79 ns         79 ns    8852605\nBM_to_string/3                    81 ns         81 ns    8612168\nBM_to_string/4                    83 ns         83 ns    8388007\nBM_to_string/5                    85 ns         85 ns    8289128\nBM_to_string/6                    86 ns         86 ns    8124345\nBM_to_string/7                    87 ns         87 ns    8049160\nBM_to_string/8                    89 ns         89 ns    7870350\nBM_to_string/9                    90 ns         90 ns    7744079\nBM_stringstream/1                 34 ns         34 ns   20586984\nBM_stringstream/2                 38 ns         38 ns   18778128\nBM_stringstream/3                 39 ns         39 ns   17165452\nBM_stringstream/4                 43 ns         43 ns   16696859\nBM_stringstream/5                 45 ns         45 ns   16127302\nBM_stringstream/6                 47 ns         47 ns   15600041\nBM_stringstream/7                 51 ns         51 ns   10000000\nBM_stringstream/8                 51 ns         51 ns   13379508\nBM_stringstream/9                 55 ns         55 ns   12981355\nBM_to_chars_naive/1               12 ns         12 ns   58830826\nBM_to_chars_naive/2               14 ns         14 ns   51283290\nBM_to_chars_naive/3               15 ns         15 ns   47083964\nBM_to_chars_naive/4               16 ns         16 ns   43907170\nBM_to_chars_naive/5               17 ns         17 ns   41087032\nBM_to_chars_naive/6               18 ns         18 ns   38062908\nBM_to_chars_naive/7               19 ns         19 ns   36324383\nBM_to_chars_naive/8               21 ns         21 ns   33114607\nBM_to_chars_naive/9               22 ns         22 ns   31397235\nBM_to_chars/1                      9 ns          9 ns   77857609\nBM_to_chars/2                     10 ns         10 ns   71753282\nBM_to_chars/3                     11 ns         11 ns   54759461\nBM_to_chars/4                     12 ns         12 ns   56404502\nBM_to_chars/5                     14 ns         14 ns   50743796\nBM_to_chars/6                     15 ns         15 ns   47294406\nBM_to_chars/7                     16 ns         16 ns   43201370\nBM_to_chars/8                     18 ns         18 ns   39207877\nBM_to_chars/9                     20 ns         20 ns   35792902\nBM_atoi/1                         14 ns         14 ns   48904147\nBM_atoi/2                         16 ns         16 ns   42837308\nBM_atoi/3                         18 ns         18 ns   39150309\nBM_atoi/4                         20 ns         20 ns   35951644\nBM_atoi/5                         21 ns         21 ns   33153980\nBM_atoi/6                         23 ns         23 ns   30722978\nBM_atoi/7                         24 ns         24 ns   28734136\nBM_atoi/8                         26 ns         26 ns   26651732\nBM_atoi/9                         28 ns         28 ns   25124905\nBM_strtol/1                       14 ns         15 ns   48394136\nBM_strtol/2                       16 ns         16 ns   42688678\nBM_strtol/3                       18 ns         18 ns   39113890\nBM_strtol/4                       20 ns         20 ns   35940516\nBM_strtol/5                       21 ns         21 ns   33045007\nBM_strtol/6                       23 ns         23 ns   30704735\nBM_strtol/7                       24 ns         24 ns   28600808\nBM_strtol/8                       26 ns         26 ns   26730526\nBM_strtol/9                       28 ns         28 ns   25050583\nBM_stoi/1                         16 ns         16 ns   44890941\nBM_stoi/2                         17 ns         17 ns   40451418\nBM_stoi/3                         19 ns         19 ns   37593651\nBM_stoi/4                         20 ns         20 ns   34442293\nBM_stoi/5                         22 ns         22 ns   31927689\nBM_stoi/6                         24 ns         24 ns   29465662\nBM_stoi/7                         25 ns         25 ns   27752163\nBM_stoi/8                         27 ns         27 ns   25848348\nBM_stoi/9                         29 ns         29 ns   24381987\nBM_from_chars_unchecked/1          4 ns          4 ns  162408633\nBM_from_chars_unchecked/2          5 ns          5 ns  132550992\nBM_from_chars_unchecked/3          6 ns          6 ns  113085260\nBM_from_chars_unchecked/4          7 ns          7 ns   96808997\nBM_from_chars_unchecked/5          8 ns          8 ns   89169648\nBM_from_chars_unchecked/6          8 ns          8 ns   82540712\nBM_from_chars_unchecked/7          9 ns          9 ns   77455690\nBM_from_chars_unchecked/8         10 ns         10 ns   73136554\nBM_from_chars_unchecked/9         10 ns         10 ns   68730597\nBM_from_chars/1                    9 ns          9 ns   78818376\nBM_from_chars/2                   10 ns         10 ns   71176282\nBM_from_chars/3                   11 ns         11 ns   63257070\nBM_from_chars/4                   12 ns         12 ns   56995175\nBM_from_chars/5                   14 ns         14 ns   50584861\nBM_from_chars/6                   15 ns         15 ns   47135520\nBM_from_chars/7                   16 ns         16 ns   43457090\nBM_from_chars/8                   17 ns         17 ns   40382499\nBM_from_chars/9                   19 ns         19 ns   37375537\n```\n\n## About\n\nThis project was created by [Erik Rigtorp](http://rigtorp.se)\n\u003c[erik@rigtorp.se](mailto:erik@rigtorp.se)\u003e.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frigtorp%2Fcharconv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frigtorp%2Fcharconv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frigtorp%2Fcharconv/lists"}