https://github.com/jart/morton Skip to content Toggle navigation Sign in * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} jart / morton Public * Notifications * Fork 6 * Star 230 * License ISC license 230 stars 6 forks Branches Tags Activity Star Notifications * Code * Issues 1 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights jart/morton This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. main BranchesTags Go to file Code Folders and files Name Name Last commit message Last commit date Latest commit History 2 Commits .gitignore .gitignore LICENSE LICENSE Makefile Makefile README.md README.md bench.c bench.c morton.c morton.c morton.h morton.h test.c test.c View all files Repository files navigation * README * ISC license Morton This repository implements bit interleaving in C/C++. morton(0b1100,0b0011) |||+--+|||| ||+-+ ||||| |++ | ||||| |+-----+||| ||| | | ||| |||+----+|| ||||| | || |||||+---+| |||||||+--+ 0b10100101 By default a SWAR implementation is used which takes 2 nanoseconds. If -mbmi2 is available, then morton() and unmorton() take less than one nanosecond. If no compiler optimizations are used then these funcs take 10 nanoseconds. The cost is constant since this implementation is fully branchless. See Also * https://en.wikipedia.org/wiki/Z-order_curve * https://graphics.stanford.edu/~seander/bithacks.html * https://stackoverflow.com/questions/30539347/ 2d-morton-code-encode-decode-64bits About No description, website, or topics provided. Resources Readme License ISC license Activity Stars 230 stars Watchers 3 watching Forks 6 forks Report repository Releases No releases published Packages 0 No packages published Languages * C 97.2% * Makefile 2.8% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.