{"id":46101538,"url":"https://github.com/xjb714/xjb","last_synced_at":"2026-04-08T06:01:29.517Z","repository":{"id":320314776,"uuid":"1081618941","full_name":"xjb714/xjb","owner":"xjb714","description":"fast float to string algorithm.","archived":false,"fork":false,"pushed_at":"2026-04-05T17:04:20.000Z","size":17595,"stargazers_count":27,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-05T19:24:40.949Z","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":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xjb714.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-23T03:30:13.000Z","updated_at":"2026-04-05T17:00:26.000Z","dependencies_parsed_at":"2025-10-31T10:08:50.910Z","dependency_job_id":null,"html_url":"https://github.com/xjb714/xjb","commit_stats":null,"previous_names":["xjb714/xjb"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/xjb714/xjb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjb714%2Fxjb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjb714%2Fxjb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjb714%2Fxjb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjb714%2Fxjb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xjb714","download_url":"https://codeload.github.com/xjb714/xjb/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xjb714%2Fxjb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31542384,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T16:28:08.000Z","status":"online","status_checked_at":"2026-04-08T02:00:06.127Z","response_time":54,"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":"2026-03-01T20:00:18.415Z","updated_at":"2026-04-08T06:01:29.494Z","avatar_url":"https://github.com/xjb714.png","language":"C++","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# xjb\r\nxjb : a fast float to string algorithm.\r\n\r\nfloat/double to string single file implementation : `src/ftoa.cpp`\r\n\r\nfor json lib, satisfy  `RFC8259` and https://tc39.es/ecma262/#sec-numeric-types-number-tostring : `src/ftoa_json.cpp`\r\n\r\nThis code is still being updated continuously, so it may not be the final version. Later, I will write documentation to explain in detail the function of each line of code and the proof process.\r\n\r\n## algorithm correctness proof:  \r\nExecute the following command to verify the correctness of the algorithm.\r\n```\r\ncd bench\r\nmake check\r\n```\r\n\r\n## todo:\r\n(1) big-endian support\r\n(2) f16, f128 and f256 support\r\n\r\n## src files:\r\n(1)float/double to decimal algorithm  \r\n\u0026emsp;\u0026emsp;   xjb32 : for float (IEEE754-binary32) ; `bench/xjb/float_to_decimal/xjb32_i.cpp`;  \r\n\u0026emsp;\u0026emsp;   xjb64 : for double(IEEE754-binary64) ; `bench/xjb/float_to_decimal/xjb64_i.cpp`;\r\n\r\n(2)float/double to string algorithm  \r\n\u0026emsp;\u0026emsp;   full lookup table : `bench/xjb/float_to_string/ftoa.cpp`  \r\n\u0026emsp;\u0026emsp;   compress lookup table : `bench/xjb/float_to_string/xjb_comp.cpp`\r\n\r\nlookup table size:\r\n\u003ctable border=\"1px\"\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd colspan=\"1\"\u003e\u003c/td\u003e\r\n        \u003ctd colspan=\"1\"\u003efull table:ftoa.cpp\u003c/td\u003e\r\n        \u003ctd colspan=\"1\"\u003ecompress table:xjb_comp.cpp\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003efloat\u003c/td\u003e\r\n        \u003ctd\u003e1352 byte\u003c/td\u003e\r\n        \u003ctd\u003e64 byte\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003edouble\u003c/td\u003e\r\n        \u003ctd\u003e15336 byte\u003c/td\u003e\r\n        \u003ctd\u003e592 byte\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\n## examples:\r\nHere are a few examples for double to string algorithm:\r\n\u003ctable border=\"1px\"\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd colspan=\"1\"\u003edouble\u003c/td\u003e\r\n        \u003ctd colspan=\"1\"\u003eprint result\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e123.45\u003c/td\u003e\r\n        \u003ctd\u003e\"123.45\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e1000\u003c/td\u003e\r\n        \u003ctd\u003e\"1000.0\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e123\u003c/td\u003e\r\n        \u003ctd\u003e\"123.0\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e123000\u003c/td\u003e\r\n        \u003ctd\u003e\"123000.0\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e1.2e23\u003c/td\u003e\r\n        \u003ctd\u003e\"1.2e23\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e1e100\u003c/td\u003e\r\n        \u003ctd\u003e\"1e100\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e0.0123\u003c/td\u003e\r\n        \u003ctd\u003e\"0.0123\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e0.001\u003c/td\u003e\r\n        \u003ctd\u003e\"0.001\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e0.000123\u003c/td\u003e\r\n        \u003ctd\u003e\"0.000123\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n        \u003ctr\u003e\r\n        \u003ctd\u003e1.2e-08\u003c/td\u003e\r\n        \u003ctd\u003e\"1.2e-08\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e0\u003c/td\u003e\r\n        \u003ctd\u003e\"0.0\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003eNaN\u003c/td\u003e\r\n        \u003ctd\u003e\"nan\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003eInf\u003c/td\u003e\r\n        \u003ctd\u003e\"inf\"\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\n\u003c!-- demo link: https://onlinegdb.com/OPKdOpikG --\u003e\r\n\r\n## Algorithm characteristics:  \r\nThis algorithm is based on the schubfach algorithm.  \r\nThis algorithm is inspired by algorithms such as schubfach, yy, dragonbox, and grisu.  \r\n(1) Support double and float  \r\n(2) Algorithm process optimization  \r\n(3) Low branch prediction failure rate  \r\n(4) Acceleration using SIMD instruction set  \r\n(5) Low instruction dependency, high IPC  \r\n(6) Fewer instructions  \r\n\r\n## benchmark:\r\nThe benchmark test is in the `bench` directory. just run `make` to build the benchmark program.\r\nyou can run `bench/main.cpp` to test the performance of the algorithm.  \r\nThe latest benchmark results on Apple M1 and AMD R7-7840H CPU(date : 2026.3.27):\r\n\u003c!-- ![ramdom float apple M1](bench_result/random_float_m1.svg)\r\n![ramdom double apple M1](bench_result/random_double_m1.svg)\r\n![ramdom float amd 7840h](bench_result/random_float_7840h.svg)\r\n![ramdom double amd 7840h](bench_result/random_double_7840h.svg) --\u003e\r\n\u003ctable\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd \u003e\u003ccenter\u003e\u003cimg src=\"bench_result/random_float_m1.svg\" \u003eramdom float on Apple M1 \u003c/br\u003e compiler: apple clang 21.0.0\u003c/center\u003e\u003c/td\u003e\r\n        \u003ctd \u003e\u003ccenter\u003e\u003cimg src=\"bench_result/random_double_m1.svg\"  \u003eramdom double on Apple M1\u003c/br\u003e compiler: apple clang 21.0.0\u003c/center\u003e\u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e\u003ccenter\u003e\u003cimg src=\"bench_result/random_float_7840h.svg\" \u003eramdom float on AMD R7-7840H \u003c/br\u003e compiler: icpx 2025.0.4\u003c/center\u003e\u003c/td\u003e\r\n        \u003ctd \u003e\u003ccenter\u003e\u003cimg src=\"bench_result/random_double_7840h.svg\"  \u003eramdom double on AMD R7-7840H\u003c/br\u003e compiler: icpx 2025.0.4\u003c/center\u003e \u003c/td\u003e\r\n    \u003c/tr\u003e\r\n    \u003ctr\u003e\r\n        \u003ctd\u003e\u003ccenter\u003e\u003cimg src=\"bench_result/fixed-length_double_m1.svg\" \u003efixed-length double on Apple M1 \u003c/br\u003e compiler: apple clang 21.0.0\u003c/center\u003e\u003c/td\u003e\r\n        \u003ctd \u003e\u003ccenter\u003e\u003cimg src=\"bench_result/fixed-length_double_7840h.svg\"  \u003efixed-length double on AMD R7-7840H\u003c/br\u003e compiler: icpx 2025.0.4\u003c/center\u003e \u003c/td\u003e\r\n    \u003c/tr\u003e\r\n\u003c/table\u003e\r\n\r\nplease refer to `bench` directory for more details.  \r\n\r\n## related algorithm\r\n\r\nalgorithm     | Description\r\n--------------|-----------\r\n[schubfach](https://github.com/abolz/Drachennest) | Raffaello Giulietti's algorithm.Origin source code from https://github.com/c4f7fcce9cb06515/Schubfach\r\nschubfach_xjb  | It is improved by schubfach and has the same output result.\r\n[ryu](https://github.com/ulfjack/ryu) | Ulf Adams's [Ryū algorithm](https://dl.acm.org/citation.cfm?id=3192369).\r\n[dragonbox](https://github.com/jk-jeon/dragonbox) | Junekey Jeon's CPP implementation.\r\n[fmt](https://github.com/fmtlib/fmt) | Victor Zverovich.https://github.com/fmtlib/fmt. version:12.1.0\r\n[yy_double](https://github.com/ibireme/c_numconv_benchmark) | yy's algorithm ,  origin link : https://github.com/ibireme/c_numconv_benchmark/blob/master/vendor/yy_double/yy_double.c\r\n[yy_json](https://github.com/ibireme/yyjson) | yy's algorithm. https://github.com/ibireme/yyjson\r\n[teju](https://github.com/cassioneri/teju_jagua) | youtube  link : https://www.youtube.com/watch?v=fPZ1ZdA7Iwc . An academic paper will be written to provide proof of correctness.https://github.com/cassioneri/teju_jagua\r\n[xjb](https://github.com/xjb714/xjb) | XiangJunBo's algorithm. https://github.com/xjb714/xjb\r\n[schubfach_vitaut](https://github.com/vitaut/schubfach) | Vitaut's algorithm. https://github.com/vitaut/schubfach\r\n[zmij](https://github.com/vitaut/zmij) | Vitaut's algorithm. https://github.com/vitaut/zmij\r\n[jnum](https://github.com/lengjingzju/json/blob/master/jnum.c) | Jing Leng's algorithm. https://github.com/lengjingzju/json/blob/master/jnum.c\r\n[uscale](https://github.com/rsc/fpfmt) | Russ Cox's algorithm. src: https://github.com/rsc/fpfmt commit 6255750 (19 Jan 2026). introduction: https://research.swtch.com/fp\r\n\r\n## acknowledgement:\r\nThanks to the following authors:\r\n\r\n* Yaoyuan Guo ([@ibireme](https://github.com/ibireme)) - Author of the yyjson and yy_double algorithm , provide benchmark data and test code. The code inspiration for this project comes from the yy algorithm.\r\n\r\n* Dougall Johnson ([@dougallj](https://github.com/dougallj)) - Authored the NEON implementation, which is used in the xjb algorithm.\r\n\r\n* Daniel Lemire ([@lemire](https://github.com/lerime)) - Authored the AVX512IFMA implementation(Convert 8/16 digit integer to decimal strings), which is used in the xjb algorithm. [code](https://lemire.me/blog/2022/03/28/converting-integers-to-decimal-strings-faster-with-avx-512/)\r\n\r\n* Raffaello Giulietti ([@rgiulietti](https://github.com/rgiulietti)) - Author of the Schubfach algorithm, whose work forms a foundational basis for xjb.\r\n\r\n\r\n## who is using this algorithm\r\n\r\n- [ssrJSON](https://github.com/Antares0982/ssrJSON) - A SIMD boosted high-performance and correct Python JSON parsing library, faster than the fastest.\r\n- [jsoniter-scala](https://github.com/plokhotnyuk/jsoniter-scala) - Scala macros for compile-time generation of safe and ultra-fast JSON codecs + circe booster.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjb714%2Fxjb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxjb714%2Fxjb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjb714%2Fxjb/lists"}