{"id":24926845,"url":"https://github.com/jaytwolab/to_string-floating-type","last_synced_at":"2025-03-28T12:26:30.124Z","repository":{"id":250833916,"uuid":"835575424","full_name":"JayTwoLab/to_string-floating-type","owner":"JayTwoLab","description":"convert floating type to string (Modern C++)","archived":false,"fork":false,"pushed_at":"2024-10-07T04:25:41.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-28T03:07:34.287Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://jaytwolab.github.io/to_string-floating-type/","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/JayTwoLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"j2doll","patreon":"j2doll","open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"yukrf5x","custom":null}},"created_at":"2024-07-30T05:52:06.000Z","updated_at":"2025-01-21T23:35:28.000Z","dependencies_parsed_at":"2024-07-30T10:45:12.502Z","dependency_job_id":"e48837b8-2c06-4ead-b104-ac8243bf9d6c","html_url":"https://github.com/JayTwoLab/to_string-floating-type","commit_stats":null,"previous_names":["jaytwolab/to_string-floating-type"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fto_string-floating-type","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fto_string-floating-type/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fto_string-floating-type/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JayTwoLab%2Fto_string-floating-type/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JayTwoLab","download_url":"https://codeload.github.com/JayTwoLab/to_string-floating-type/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246028538,"owners_count":20712038,"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":"2025-02-02T12:53:28.598Z","updated_at":"2025-03-28T12:26:30.088Z","avatar_url":"https://github.com/JayTwoLab.png","language":"C++","readme":"# to_string-floating-type\n\n- C++ function to convert floating type to string ```to_string\u003cT\u003e```\n\n```cpp\nvoid test1(void)\n{\n    float  f = 10.12f;\n    double d = 10.12;\n\n    std::cout \u003c\u003c std::fixed\n              \u003c\u003c f    // 10.120000\n              \u003c\u003c \" \"\n              \u003c\u003c d    // 10.120000\n              \u003c\u003c std::endl;\n    \n    std::cout \u003c\u003c std::fixed\n              \u003c\u003c j2::to_string\u003cfloat\u003e(f)  // 10.119999886 \n              \u003c\u003c \" \"\n              \u003c\u003c j2::to_string\u003cdouble\u003e(d) // 10.11999999999999922 \n              \u003c\u003c std::endl;\n    \n    std::cout \u003c\u003c std::fixed\n              \u003c\u003c j2::to_string\u003cfloat\u003e(f, 2)  // 10.12\n              \u003c\u003c \" \"\n              \u003c\u003c j2::to_string\u003cdouble\u003e(d, 2) // 10.12\n              \u003c\u003c std::endl;\n    \n    std::cout \u003c\u003c std::fixed\n              \u003c\u003c j2::to_string\u003cfloat\u003e(f,10)  // 10.1199998856 \n              \u003c\u003c \" \"\n              \u003c\u003c j2::to_string\u003cdouble\u003e(d,20) // 10.11999999999999921840\n              \u003c\u003c std::endl;\n}\n```\n\n- C++ function to compare floating type to string ```is_equal\u003cT\u003e```\n\n```cpp\nvoid test_double(double d1, double d2, long long precision)\n{\n    bool ret = j2::is_equal\u003cdouble\u003e(d1, d2, precision);\n\n    if (ret) { std::cout \u003c\u003c \"[equal] \"; } else { std::cout \u003c\u003c \"[not equal] \"; }\n\n    std::cout \u003c\u003c std::fixed\n              \u003c\u003c j2::to_string\u003cdouble\u003e(d1, precision) \u003c\u003c \" \" \u003c\u003c j2::to_string\u003cdouble\u003e(d2, precision)\n              \u003c\u003c std::endl;\n}\n\nvoid test2()\n{\n    test_double(10.12, 10.12,       2); // [equal]     10.12  10.12\n    test_double(10.12, 10.1,        1); // [equal]     10.1   10.1\n    test_double(10.12, 10.12,       3); // [equal]     10.120 10.120\n    test_double(10.12, 10.121,      3); // [not equal] 10.120 10.121\n    test_double(10.12, 10.121,     20); // [not equal] 10.11999999999999921840 10.12100000000000044054\n    test_double(10.12, 10.1201,    20); // [not equal] 10.11999999999999921840 10.12010000000000076170\n    test_double(10.12, 10.12001,   20); // [not equal] 10.11999999999999921840 10.12001000000000061618\n    test_double(10.12, 10.120001,  20); // [not equal] 10.11999999999999921840 10.12000100000000024636\n    test_double(10.12, 10.1200001, 20); // [not equal] 10.11999999999999921840 10.12000010000000038701\n    test_double(10.12, 10.12,      10); // [equal] 10.1200000000 10.1200000000\n}\n```\n\n## License\n- to_string-floating-type is under MIT License. https://github.com/j2doll/to_string-floating-type\n- It is a part of JayTwo(j2) Library. \n\n\n\n","funding_links":["https://github.com/sponsors/j2doll","https://patreon.com/j2doll","https://buymeacoffee.com/yukrf5x"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaytwolab%2Fto_string-floating-type","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaytwolab%2Fto_string-floating-type","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaytwolab%2Fto_string-floating-type/lists"}