{"id":17722803,"url":"https://github.com/bramp/bithacks","last_synced_at":"2025-10-15T22:42:10.528Z","repository":{"id":220227822,"uuid":"751086266","full_name":"bramp/bithacks","owner":"bramp","description":"A collection of bit twiddling hacks in dart","archived":false,"fork":false,"pushed_at":"2024-03-08T17:43:57.000Z","size":36,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-14T14:16:13.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/bithacks","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bramp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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},"funding":{"github":"bramp","buy_me_a_coffee":"bramp"}},"created_at":"2024-01-31T22:36:43.000Z","updated_at":"2024-12-06T07:37:23.000Z","dependencies_parsed_at":"2024-10-25T19:58:56.539Z","dependency_job_id":"c6da7b18-9402-4fe6-9502-212efd864f58","html_url":"https://github.com/bramp/bithacks","commit_stats":null,"previous_names":["bramp/bithacks"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bramp/bithacks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fbithacks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fbithacks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fbithacks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fbithacks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bramp","download_url":"https://codeload.github.com/bramp/bithacks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bramp%2Fbithacks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259905430,"owners_count":22929917,"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-10-25T15:39:25.133Z","updated_at":"2025-10-15T22:42:05.474Z","avatar_url":"https://github.com/bramp.png","language":"Dart","funding_links":["https://github.com/sponsors/bramp","https://buymeacoffee.com/bramp"],"categories":[],"sub_categories":[],"readme":"# bithacks\n\nby Andrew Brampton ([bramp.net](https://bramp.net))\n\nCollection of bit twiddling hacks. Think\n[popcount](https://en.cppreference.com/w/cpp/numeric/popcount) or _pdep_u64.\nWorks on both Dart VM and dart2js.\n\n[GitHub](https://github.com/bramp/bithacks) | [Package](https://pub.dev/packages/bithacks) | [API Docs](https://pub.dev/documentation/bithacks/latest/)\n\n\n## Usage\n\n```dart\n  // Count the number of bits set.\n  0.bitCount(); // returns 0\n  1.bitCount(); // returns 1\n  2.bitCount(); // returns 1\n  3.bitCount(); // returns 2\n  0x10101010.bitCount(); // returns 4\n\n  // Find the position of set bits. For example:\n  //\n  //   7 6 5 4 3 2 1 0 (index)\n  //   0 1 0 0 0 0 1 1 (value 0x43 with 3 bits set)\n  //     2         1 0 (rank)\n  //\n  0x43.bitRank(0); // returns 0   (found at index 0)\n  0x43.bitRank(1); // returns 1   (found at index 1)\n  0x43.bitRank(2); // returns 6   (found at index 6)\n  0x43.bitRank(3); // returns -1  (not found)\n```\n\n## Development\n\nTo run the tests:\n\n```bash\ndart test\ndart test -p chrome\n```\n\nTo publish:\n\n```bash\ndart analyze\n\n# Bump the version in pubspec.yaml\n# Update the CHANGELOG.md\n\ndart pub lish\n```\n\n## Additional information\n\nThese algorithms were inspired by [Bit Twiddling Hacks](https://graphics.stanford.edu/~seander/bithacks.html)\nby Sean Eron Anderson\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramp%2Fbithacks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbramp%2Fbithacks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbramp%2Fbithacks/lists"}