{"id":1806,"date":"2023-02-14T17:53:16","date_gmt":"2023-02-14T16:53:16","guid":{"rendered":"https:\/\/blogs.gentoo.org\/mgorny\/?p=1806"},"modified":"2023-02-14T17:53:16","modified_gmt":"2023-02-14T16:53:16","slug":"x-alpha-hexadecimal-notation","status":"publish","type":"post","link":"https:\/\/blogs.gentoo.org\/mgorny\/2023\/02\/14\/x-alpha-hexadecimal-notation\/","title":{"rendered":"X-alpha hexadecimal notation"},"content":{"rendered":"<p>The most common way to represent hexadecimal (or any other base &gt; 10) numbers is to use the first letters of alphabet for the extra digits.  However, this doesn&#8217;t work well for my brain that insists that since A is the first letter, B is the second letter\u2026 then A = 10 + 1, B = 10 + 2\u2026  so I keep having to remember to shift this by one, and judging by <a rel=\"external\" href=\"https:\/\/fosstodon.org\/@mgorny\/109861819319577804\">the responses to my toot about it<\/a>, it seems that I&#8217;m not alone.<\/p>\n<p>I don&#8217;t think that I&#8217;ve made any useless invention that people would randomly find and say &#8220;oh, hey, what a nice unrealistic idea&#8221;.  It&#8217;s time to make one!  I present to you: the X-alpha hexadecimal notation!<br \/>\n<!--more--><br \/>\nLet&#8217;s start with the digits of the traditional hex notation:<\/p>\n<blockquote><p>\n0 1 2 3 4 5 6 7 8 9 A B C D E F\n<\/p><\/blockquote>\n<p>The Hindu-Arabic numerals are fine.  The letters have the &#8220;shift&#8221; effect, so let&#8217;s move them to the places that work better for my decimal brain:<\/p>\n<blockquote><p>\n0 1 2 3 4 5 6 7 8 9 \u2026 A B C D E\n<\/p><\/blockquote>\n<p>However, this creates a gap: what to use for 10?  I&#8217;ve been thinking about it and realized that we have a well-known symbol for 10 already!  The sequence becomes:<\/p>\n<blockquote><p>\n0 1 2 3 4 5 6 7 8 9 \u2169 A B C D E\n<\/p><\/blockquote>\n<p>However, this system has a significant flaw: it&#8217;s easy to confuse a number with the ABCDEF notation.  So let&#8217;s replace the Latin letters with, say, Greek letters \u2014 and I just happen to remember the first five!  Let&#8217;s use lowercase forms though since they&#8217;re more easily distinguished from the Latin alphabet.<\/p>\n<blockquote><p>\n0 1 2 3 4 5 6 7 8 9 \u2169 \u03b1 \u03b2 \u03b3 \u03b4 \u03b5\n<\/p><\/blockquote>\n<p>Tadaam!  Finally, a quick way to convert between the standard and X-alpha representation in Python:<\/p>\n<pre><code>\"0x3f7a5d\".translate(str.maketrans(\"abcdef\", \"\u2169\u03b1\u03b2\u03b3\u03b4\u03b5\"))<\/code><\/pre>\n<p>\u2026and the other way around:<\/p>\n<pre><code>\"3\u03b556\u2169\u03b3\".translate(str.maketrans(\"\u2169\u03b1\u03b2\u03b3\u03b4\u03b5\", \"abcdef\"))<\/code><\/pre>\n<p>Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The most common way to represent hexadecimal (or any other base &gt; 10) numbers is to use the first letters of alphabet for the extra digits. However, this doesn&#8217;t work well for my brain that insists that since A is the first letter, B is the second letter\u2026 then A = 10 + 1, B &hellip; <a href=\"https:\/\/blogs.gentoo.org\/mgorny\/2023\/02\/14\/x-alpha-hexadecimal-notation\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;X-alpha hexadecimal notation&#8221;<\/span><\/a><\/p>\n","protected":false},"author":137,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[8],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/1806"}],"collection":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/users\/137"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/comments?post=1806"}],"version-history":[{"count":7,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/1806\/revisions"}],"predecessor-version":[{"id":1813,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/posts\/1806\/revisions\/1813"}],"wp:attachment":[{"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/media?parent=1806"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/categories?post=1806"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.gentoo.org\/mgorny\/wp-json\/wp\/v2\/tags?post=1806"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}