Practitioners in computer science often must convert between three major positional numeral systems: binary, octal, and hexadecimal. Binary is short for base two, consisting only of ones and zeros, and is used in the construction of circuits and components, such as a central processing unit. Octal is short for base eight and can serve as a way to group binary digits together in sets of three. Hexadecimal is short for base sixteen. Like octal, hexadecimal can also be used to group binary digits in groups of four. As binary sequences get longer, the ability to group digits together as shorthand becomes essential.
In this series of posts, the reader will come to understand these three number bases in the context of counting in any number base. We’ll first cover the concept of a radix, or number base, with an eye toward the historical aspects of counting. From there we’ll leverage our understanding of radix to convert decimal values to binary, octal, and hexadecimal and back. Once we’ve explored these specific radices we examine the idea of radix economy, and answer the question, “Is there a radix with optimal efficiency?”
The next couple of articles focuses specifically on binary, as this radix is the basis for how all information is represented in a computer. Here we examine binary vernacular, such as the kilobit or megabyte, as well as Boolean logic. Further on we explore negative value representations using binary including the popular two’s-complement method. To round out our discussion of arbitrary bases we experiment with non-standard positional notations such as balanced ternary, a form of base three, and other obscure counting odds and ends.
This article puts forth a brief history of counting, which details how we arrived at some of the conventions we have today including the notion of radix. It then explores the concept of radix in positional numeral systems, in particular the concept of using radices of arbitrary values.
This article builds upon the previous article by outlining three important radices (binary, octal, and hexadecimal) that are useful in the field of computer science. I start with arbitrary base conversion using two methods. Then, a bit of background is given for why these bases are important, particularly binary. Finally, we perform radix conversion.
This article begins with a recap of where we are in the series in regards to the concept of counting. I review the definition of positional notation as outlined in the first article and then move on to reveal how we can calculate the number of digits a value will have in a given radix. In doing so I will go over two mathematical concepts relevant to this calculation: exponents and logarithms. I will then use logarithms to show how you can calculate the efficiency of a given radix, also called the radix economy, and answer the question, “What’s the most efficient radix?”
This article continues the trend of the previous articles and begins with a history of binary. After that, I briefly reiterate why binary is used in modern electronic devices as covered in the previous article, and go into more depth regarding binary “sizes” (bit, byte, kilobyte, etc.) Then I move on to important elements of binary arithmetic, and the operations of addition, subtraction, multiplication, and division. I cover two operations often found in computing processors, the shift operators, and their mathematical meaning. Finally, I briefly cover Boolean logic operations.
A non-standard positional notation is one where the value of each position isn’t necessarily a straightforward power of the radix. I am also including when the radix is not a positive integer (such as -2), even though mathematically the representation is consistent with standard positional notation. By altering the interpretation of one or more of the place values (or the radix) of a binary representation, we are able to represent negative values. In this post I’ll be covering sign-magnitude, the most intuitive method, the radix complement methods (ones’ complement and two’s complement), offset binary (also known as excess-k or biased), and base -2 (base negative two).