{"id":24740603,"url":"https://github.com/mariosieg/bit-twiddling-hacks-collection","last_synced_at":"2025-10-10T08:31:02.586Z","repository":{"id":45957137,"uuid":"281523107","full_name":"MarioSieg/Bit-Twiddling-Hacks-Collection","owner":"MarioSieg","description":"A single C header with many bitwise hacks","archived":false,"fork":false,"pushed_at":"2021-11-27T10:58:32.000Z","size":290,"stargazers_count":30,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-03T18:51:24.640Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MarioSieg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-21T23:07:27.000Z","updated_at":"2025-03-09T17:33:27.000Z","dependencies_parsed_at":"2022-09-02T18:41:22.240Z","dependency_job_id":null,"html_url":"https://github.com/MarioSieg/Bit-Twiddling-Hacks-Collection","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MarioSieg/Bit-Twiddling-Hacks-Collection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FBit-Twiddling-Hacks-Collection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FBit-Twiddling-Hacks-Collection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FBit-Twiddling-Hacks-Collection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FBit-Twiddling-Hacks-Collection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MarioSieg","download_url":"https://codeload.github.com/MarioSieg/Bit-Twiddling-Hacks-Collection/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MarioSieg%2FBit-Twiddling-Hacks-Collection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003299,"owners_count":26083555,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"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":"2025-01-27T23:24:45.488Z","updated_at":"2025-10-10T08:31:02.289Z","avatar_url":"https://github.com/MarioSieg.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"A single C header files containing functions with different bit twiddling hacks and a short explanation.\nI've put them together for myself as a cheatsheet and to play around with them.\nIf you know any hacks not included, just submit a PR, or if you encounter any wrong stuff or a typo!\n\nShort hack assortment:\n* Number multiplication, division\n* Even, odd and power checks\n* Uppercase, lowercase\n* Set, clear and flip bits\n* Insert and extract bitfields into words\n* Convert LSL, MSB, trailing bits\n* Masked copy\n* Bit swap\n* Population count\n* Bit island count\n* Bit scans\n* Lexiocographic permutations\n* Swapping without temporaries\n* Size comparison: min() and max() functions without branching\n* Modular additions\n* Power rounding\n* Significant masking\n* Logbase2 of power2 calculation using deBruijin sequence\n* Fast inverse sqrt\n* Bit reversion\n* Masked color operations\n* XOR en/decryption\n* Branchless assignments\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosieg%2Fbit-twiddling-hacks-collection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmariosieg%2Fbit-twiddling-hacks-collection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmariosieg%2Fbit-twiddling-hacks-collection/lists"}