{"id":21850590,"url":"https://github.com/freakwill/digit_converter","last_synced_at":"2025-07-11T20:07:38.730Z","repository":{"id":62568233,"uuid":"219403521","full_name":"Freakwill/digit_converter","owner":"Freakwill","description":"A cool tool for digits converting. It could be applied in GA.","archived":false,"fork":false,"pushed_at":"2023-11-28T03:20:32.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-26T02:40:43.638Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","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/Freakwill.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":"2019-11-04T02:46:18.000Z","updated_at":"2021-10-13T07:35:50.000Z","dependencies_parsed_at":"2025-03-21T17:49:11.845Z","dependency_job_id":"76cc5b7b-6895-4590-b1c9-e42de5587b45","html_url":"https://github.com/Freakwill/digit_converter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Freakwill/digit_converter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fdigit_converter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fdigit_converter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fdigit_converter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fdigit_converter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Freakwill","download_url":"https://codeload.github.com/Freakwill/digit_converter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Freakwill%2Fdigit_converter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264890087,"owners_count":23678833,"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-11-28T00:18:18.662Z","updated_at":"2025-07-11T20:07:38.705Z","avatar_url":"https://github.com/Freakwill.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# digit_converter\n\nA useful tool for digit conversion, applicable in Genetic Algorithms (GA). It transforms a number into a list of digits under any base, for example, `[1, 0, 1, 0, 1, 1, 1, 0] \u003c-\u003e 174`. 🔢\n\n## Abstract\n\nA cool tool for digits converting. It transforms a number to a list and verse vice, such as represent a number by a binary list.\nIt could be applied in GA.\n\n**Keywords** Converter, Digits\n\n## Classes and Objects\n\nClasses:\n```\n    BaseConverter: \n        .tonumber(lst), .tolist(num, L)\n        \n    DigitConverter:\n    BinaryConverter: subclass of DigitConverter\n    IntervalConverter\n```\nObjects:\n```\n    colorConverter: instance of BinaryConverter\n    unitIntervalConverter: instance of IntervalConverter  == IntervalConverter(lb=0, ub=1)\n```\n\n## Grammar\nInstall the lib, by `pip install digit_converter`\n\n### Import\n\n```python\nimport digit_converter\n```\n\n### Basic usage\n\n```pyhon\nprint('=*= Example 1 =*=')\nprint(f'color-converter: {colorConverter.tonumber([1,0,1,0,1,1,1,0])}\u003c-\u003e{colorConverter.tolist(174)}')\n\nprint('=*= Example 2 =*=')\nc = BinaryConverter(exponent=3)\nd = c.tolist(12.223, L=8)\nprint(f'binary-converter: {d}\u003c-\u003e{c.tonumber(d)}={c.pretty(d)}')\ni, f = c.seperate(12.223, L=8)\nprint(f'integer part: {i}, fractional part: {f}')\n\nprint('=*= Example 3 =*=')\nc = IntervalConverter(lb=0, ub=10)\nd = c.tolist(2.4, L=8)\nprint(f'[{c.lb},{c.ub}]-converter: {d}\u003c-\u003e{c(d)} -\u003e {c.pretty(d)}-th number')\n\nprint('=*= Example 4 =*=')\nc = DigitConverter(base=16)\nd = c.tolist(2.4, L=8)\nprint(f'16-converter: {d}\u003c-\u003e{c(d)}={c.pretty(d)}')\n```\n\nOUTPUT::\n\n    =*= Example 1 =*=\n    color-converter: 174\u003c-\u003e[1, 0, 1, 0, 1, 1, 1, 0]\n    =*= Example 2 =*=\n    binary-converter: [1, 1, 0, 0, 0, 0, 1, 1]\u003c-\u003e12.1875=2^{3} + 2^{2} + 2^{-3} + 2^{-4}\n    integer part: [1, 1, 0, 0], fractional part: [0, 0, 1, 1]\n    =*= Example 3 =*=\n    [0,10]-converter: [0, 0, 1, 1, 1, 1, 0, 1]\u003c-\u003e2.3828125 -\u003e 2^{5} + 2^{4} + 2^{3} + 2^{2} + 2^{0}-th number\n    =*= Example 4 =*=\n    16-converter: [0, 2, 6, 6, 6, 6, 6, 6]\u003c-\u003e2.399999976158142=2*16^{0} + 6*16^{-1} + 6*16^{-2} + 6*16^{-3} + 6*16^{-4} + 6*16^{-5} + 6*16^{-6}\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreakwill%2Fdigit_converter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffreakwill%2Fdigit_converter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffreakwill%2Fdigit_converter/lists"}