{"id":187,"date":"2006-10-16T21:34:29","date_gmt":"2006-10-16T21:34:29","guid":{"rendered":"http:\/\/scientopia.org\/blogs\/goodmath\/2006\/10\/16\/a-bit-about-number-bases\/"},"modified":"2006-10-16T21:34:29","modified_gmt":"2006-10-16T21:34:29","slug":"a-bit-about-number-bases","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2006\/10\/16\/a-bit-about-number-bases\/","title":{"rendered":"A Bit About Number Bases"},"content":{"rendered":"<p>After my binary fingermath stuff, a few people wrote to me to ask about just how binary really works. For someone who does the kinds of crazy stuff that I do, the idea of different number bases is so fundamental that it&#8217;s easy to forget that most people really don&#8217;t understand the idea of using different bases.<br \/>\nTo start off with, I need to explain how our regular number system works. Most people understand how our numbers work, but don&#8217;t necessarily understand *why* they&#8217;re set up that way.<br \/>\nOur number system is *positional* &#8211; that is, what a given digit of a number means is dependent on its position in the number. The positions each represent one power of ten, increasing as you go from right to left, which is why our number system is called base-10. You can do positional numbers using any number as the base &#8211; each digit will correspond to a power of the base.<br \/>\nSo suppose we have a number like 729328. The first position from the right, containing the digit &#8220;8&#8221; is called position zero, because it tells us how many 10<sup>0<\/sup>=1s we have. The next position is position 1, or the 10<sup>1<\/sup>=10s column, because it says how many tens there are (2). And then we have the digit three in position 2, meaning that there are 3 10<sup>2<\/sup>s = 3 100s, etc.  So the number really means 7&times;10<sup>5<\/sup>+2&times;10<sup>4<\/sup>+9&times;10<sup>3<\/sup>+3&times;10<sup>2<\/sup>+2&times;10<sup>1<\/sup>+8&times;10<sup>0<\/sup> = 7&times;100,000 + 2&times;10,000 + 8&times;1,000 + 3&times;100 + 2&times;10 + 8&times;1. Now let&#8217;s look at the same kind of thing in base 3, using the number 102120. That&#8217;s 1&times;3<sup>5<\/sup> + 0&times;3<sup>4<\/sup>+2&times;3<sup>3<\/sup>+1&times;3<sup>2<\/sup>+2&times;3<sup>1<\/sup>+0&times;3<sup>0<\/sup> = 1&times;254+0&times;81+2&times;27+1&times;9+2&times;3+0&times;1 = 254 + 54 + 9 + 6 = 323 in base 10.<br \/>\n<img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" alt=\"radix.jpg\" src=\"https:\/\/i0.wp.com\/scientopia.org\/img-archive\/goodmath\/img_88.jpg?resize=308%2C206\" width=\"308\" height=\"206\" \/><br \/>\nNormally, to show that we&#8217;re using a different base, we&#8217;d write the numbers with a subscript showing the base &#8211; so we&#8217;d normally write the binary for 11 as 1011<sub>2<\/sub>.<br \/>\nTo write numbers in bases larger than 10, we have one very small problem, which is that we only have numbers to write digits from 0 to 9, but hex has digits from 0 to 15. The way that we work around that is by using letters of the alphabet: A=10, B=11, C=12, D=13, E=14, F=15, &#8230; So base-16 uses 0-9 and A-F as digits.<br \/>\nBase-8 (octal) and base-16 (hexidecimal, or hex for short) are special to a lot of computer people. The reason for that is that because 8 and 16 are powers of 2, that means that each digit in octal and hexidecimal corresponds exactly to a specific number of binary digits. Every digit in hexidecimal is something between 0 and 15, which corresponds to exactly 4 binary digits. Base-10 doesn&#8217;t have this property &#8211; a digit in base ten takes *between* three and four digits &#8211; and that means that you *can&#8217;t* divide up a string of binary into parts that correspond to decimal digits without looking at the number. With hexidecimal, every hex-digit is 4 binary digits, which is remarkably convenient.<br \/>\nWhy would that make a difference? Well, we store data in memory in 8-bit groups called bytes. How big a number can you store in one byte? 255. That&#8217;s a strange looking number. But what about in hexidecimal? It&#8217;s the largest number you can write in 2 digits: FF<sub>16<\/sub>. It gets worse as you get bigger. If you&#8217;ve got a computer that has bytes of memory numbered using 4 byte addresses, what&#8217;s the largest memory address? In hex, it&#8217;s easy to write: FFFFFFFF<sub>16<\/sub>.  In decimal? 4294967296. The hex numbers are a lot more natural to work with when you&#8217;re doing something close to the hardware. In modern programming, we rarely use hex anymore, but a few years ago, it was absolutely ubiquitous. I used to be able to do arithmetic in hex as naturally as I can in decimal. Not anymore; I&#8217;ve gotten rusty.<br \/>\nAmong computer geeks, there&#8217;s an old argument that number systems based on powers of two are more natural than others, but I&#8217;m not going to get into *that* basket of worms. If you&#8217;re interested, take a look at the [Intuitor Hex Headquarters](http:\/\/www.intuitor.com\/hex\/).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>After my binary fingermath stuff, a few people wrote to me to ask about just how binary really works. For someone who does the kinds of crazy stuff that I do, the idea of different number bases is so fundamental that it&#8217;s easy to forget that most people really don&#8217;t understand the idea of using [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[43],"tags":[],"class_list":["post-187","post","type-post","status-publish","format-standard","hentry","category-numbers"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-31","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=187"}],"version-history":[{"count":0,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/187\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=187"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}