{"id":21260477,"url":"https://github.com/tanmayvaij/number-conversions","last_synced_at":"2025-03-15T06:44:40.995Z","repository":{"id":153628649,"uuid":"541462810","full_name":"tanmayvaij/number-conversions","owner":"tanmayvaij","description":"Basic number conversion algorithms","archived":false,"fork":false,"pushed_at":"2022-09-26T12:49:34.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-21T21:47:40.813Z","etag":null,"topics":["algorithms","conversion","cpp","number","number-conversion","number-system"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanmayvaij.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-09-26T07:35:55.000Z","updated_at":"2022-10-19T10:55:06.000Z","dependencies_parsed_at":"2023-05-28T19:00:23.235Z","dependency_job_id":null,"html_url":"https://github.com/tanmayvaij/number-conversions","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/tanmayvaij%2Fnumber-conversions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fnumber-conversions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fnumber-conversions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanmayvaij%2Fnumber-conversions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanmayvaij","download_url":"https://codeload.github.com/tanmayvaij/number-conversions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243695537,"owners_count":20332626,"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":["algorithms","conversion","cpp","number","number-conversion","number-system"],"created_at":"2024-11-21T04:19:08.617Z","updated_at":"2025-03-15T06:44:40.989Z","avatar_url":"https://github.com/tanmayvaij.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Number Conversions\n\u003cbr/\u003e\n\n### Binary To Decimal\n\n```cpp\nint binToDec(int n) {\n\n    int decimal = 0, i = 0;\n\n    while ( n != 0 ) {\n\n        int digit = n % 10;\n        n /= 10;\n        decimal += digit * pow(2, i);\n        i++;\n\n    }\n\n    return decimal;\n\n}\n```\n\u003cbr/\u003e\n\n### Octal To Decimal\n\n```cpp\nint octToDec(int n) {\n\n    int decimal = 0, i = 0;\n\n    while ( n != 0 ) {\n        int digit = n % 10;\n        n /= 10;\n        decimal += digit * pow(8, i);\n        i++;\n    }\n\n    return decimal;\n\n}\n```\n\u003cbr/\u003e\n\n### Hexadecimal To Decimal\n\n```cpp\nint hexToDec( string n ) {\n\n    int decimal = 0, s = n.size(), x = 0;\n\n    for ( int i = s-1; i \u003e= 0; i-- ) {\n\n        if ( n[i] \u003e= '0' \u0026\u0026 n[i] \u003c= '9' ) \n            decimal += (n[i] - '0') * pow(16, x);\n\n        else if ( n[i] \u003e= 'A' \u0026\u0026 n[i] \u003c= 'F' ) \n            decimal += (n[i] - 'A' + 10) * pow(16, x);\n\n        x++;\n\n    }\n\n    return decimal;\n\n}\n```\n\u003cbr/\u003e\n\n### Decimal To Binary\n\n```cpp\nint decToBin(int n) {\n\n    int binary = 0, i = 0;\n\n    while ( n != 0 ) {\n        binary += (n % 2) * pow(10, i);\n        n /= 2;\n        i++;\n    }\n\n    return binary;\n\n}\n```\n\u003cbr/\u003e\n\n### Decimal To Octal\n\n```cpp\nint decToOct(int n) {\n\n    int octal = 0, i = 0;\n\n    while ( n != 0 ) {\n        octal += (n % 8) * pow(10, i);\n        n /= 8;\n        i++; \n    }\n\n    return octal;\n\n}\n```\n\u003cbr/\u003e\n\n### Decimal To Hexadecimal\n\n```cpp\nstring decToHex(int n) {\n\n    string hexadecimal = \"\";\n    int i = 0;\n    char c;\n\n    while ( pow(16, i) \u003c n ) i++;\n    i -= 1;\n\n    while( n != 0 ) {\n\n        int pow16 = pow(16, i);\n        int digit = n / pow16;\n        n %= pow16;\n\n        if ( digit \u003e 9 ) c = digit + 55; \n        else c = digit + 48;\n\n        hexadecimal.push_back(c);\n\n        i--;\n\n    }\n\n    return hexadecimal;\n\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanmayvaij%2Fnumber-conversions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanmayvaij%2Fnumber-conversions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanmayvaij%2Fnumber-conversions/lists"}