1. Introduction

In this tutorial, we’ll learn the basic concepts associated with alternative numeral systems and the reasons for their existence.

We’ll first discuss numeral systems in general, and in relation to the problem of grouping things into sets.

Then we’ll study the most common numeral system: the decimal system. As an alternative to it, we’ll also learn about the second most common numeral systems: the binary, the octal, and the hexadecimal systems.

At the end of this tutorial, we’ll be familiar with the most and the slightly less common numeral systems in use today.

2. Numeral Systems and Why They Exist

2.1. What Is a Numeral System?

A numeral system is a system for writing down and using numbers. The numeral system tells us the rules according to which we combine symbols to express numbers, and put them in relation with one another. It’s based upon the more fundamental notions of numbers and sets, which we here discuss shortly.

Among the two concepts, numbers and sets, the concept of sets is the more fundamental one. It might be surprising to learn this since we’re used to thinking that counting is the basis of all mathematical knowledge. This is, at least, the first thing that they teach us in school.

Counterintuitively, though, in mathematical philosophy numbers are not considered to be basic concepts of the discipline. Instead, they are derived from the concepts of sets and their similarity. The number of a set, according to Russel’s definition, is the set of all sets that are similar to that original set.

If that is the case, we could then also say that the numeral system is the system of rules by which we can compare the sets of all sets that are dissimilar to one another.

2.2. What Does This Mean, in Practice?

Let’s take an example to clarify this further. Let’s assume that only one class of objects exists in the universe; as we all know, in fact, everything in the universe is either a duck or not a duck:

Rendered by QuickLaTeX.com

Let’s now say that only one such duck exists and that the universe, therefore, comprises only these two sets:

U=\{\text{duck}\}, V=\{\O\}

2.3. The Simplest Numeral System

In this universe, if we want to refer to the dimensionality of the set of all things that exist, we only need one symbol. We could, for example, write down a vertical tally mark “|” whenever we are referring to our only object in existence. Of course, if we’re not referring to it, we’d simply avoid writing any marks.

We could therefore use this table of correspondence between symbols and objects, and be perfectly descriptive of everything that exists:

Rendered by QuickLaTeX.com

If our duck were however to replicate itself, we’d need to add one more tally mark in order to represent any additional element:

Rendered by QuickLaTeX.com

2.4. It Works With Other Objects, Too

Notice how the procedure can be repeated indefinitely if we keep adding extra objects to the set of objects. We can simply add one extra mark to the string of marks, for any extra object that we add to the set of objects.

Notice also how this procedure works equally well with objects other than ducks. We can, in fact, imagine a list of all classes of objects in the universe, and create a table such as the one above for the sets comprising each one of them exclusively.

In doing so, we can still assign tally marks as we did before, to each set according to their cardinality. If we do that, we could then use a specific string of tally marks in order to refer to all possible sets to which that string is associated, regardless of the nature of the objects contained therein. To rephrase the definition of a number that we gave above, we can think of the tally marks of a set as the symbols indicating the set of all sets of objects that are associated with those specific tally marks.

2.5. Positional Numeral Systems

A system that uses a unique symbol and its repetition to represent a number is called a unary system. The numeral system that we studied in the previous section falls into this category.

Notice that the system we described is special because it’s non-positional. If we swap any two given tally marks in a string of marks, in fact, the number that the string represents remains unchanged.

Most numeral systems in use today are, however, positional. That is to say, it matters the order in which we write the symbols in a string that represents a number.

This is because, in order to avoid writing excessive amounts of symbols, we can use some symbols and their positions in order to represent repetitions of the others. All numeral systems that we study below fall under this category of positional systems, which means that the order of writing symbols matters for them.

3. The Decimal System

The most common numeral system is the decimal system, which is the one we use in day-to-day life. The decimal system comprises ten symbols, the ten decimal digits with which we’re familiar. It’s common today to consider the first element in the list of symbols like the one that describes the empty set; however, this is a relatively recent acknowledgement.

The symbols we use to represent numbers in the decimal system are:

\{0,1,2,3,4,5,6,7,8,9\}

We can say that a number written with the decimal system is in base-10. We can indicate that a number is expressed in base-10 by using the subscript _{10} immediately after a number. For example, the number 42 expressed in base-10 would be written as 42_{10}, or simply as 42 whenever the base is unambiguous.

Because this is the most common system, we’ll use it as a reference to study other systems.

4. What Bases Are Alternatives of Ten

4.1. The Binary System

The binary system is the numeral system most closely associated with computers. It uses two digits, typically 1 and 0, in order to represent any number:

\{0,1\}

Because it uses only two symbols, we say that this system is a base-2 system. The two digits may correspond to, respectively:

The binary system, but not other numeral systems, has a special name for the individual digits in a string of digits that comprise a number. These are called bits, which are often used as a synonym for binary digits when we refer to information stored in a computer.

4.2. Converting Into Binary

A number can be expressed in binary notation as an ordered sequence of bits. We can convert a decimal number into a binary number by repeatedly subtracting all reverse-order powers of two. For example, let’s convert into binary the decimal number 42_{10}:

  1. The largest power of two that fits into 42_{10} is 2^5=32, which gives a difference of 10
  2. The largest power of two that fits into 10 is 2^3 = 8, which gives a difference of 2
  3. The largest power of two that fits into two is 2^1=2, which gives no difference

Then, we enumerate all power of two up to the largest that we considered, and write their associated coefficients:

42_{10} = 1 \times 2^5 + 0 \times 2^4 + 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 0 \times 2^0

The binary number that corresponds to the decimal number is then the string comprising the coefficients of the powers of two, in decreasing order:

42_{10} = 101010_2

When we write a binary number with pen and paper we usually order the digits from the smallest, which goes on the right, to the largest, which goes on the left. Notice however that, when the number we’re writing comprises a word that we copy into the memory of a computer, the order of writing may differ.

4.3. The Octal System

The octal system is a base-8 numeral system. Its digits correspond to the first 8 digits of the decimal notation:

\{0,1,2,3,4,5,6,7\}

This system was traditionally used in astrological practices in East Asia, but also in aiding the war efforts in XVIII century Sweden. Further, it’s also used in digital calculators to control the display of segments that compose a number in a LED screen.

This system has some numerical advantages for calculating powers and logarithms. In fact, by using this system we can easily write down all powers of 2:

  • 2^3_{10} = 10_8
  • 2^4_{10} = 20_8
  • 2^5_{10} = 40_8
  • 2^6_{10} = 100_8
  • 2^7_{10} = 200_8
  • 2^8_{10} = 400_8

A similar property is also shared by the hexadecimal system, though, which makes the usage of the octal system somewhat limited.

4.4. The Hexadecimal System

The hexadecimal system uses 16 symbols to represent digits. Because the digits used in most human languages amount to just 10, it’s conventional to add the first six letters of the alphabet after the ten digits:

\{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F\}

The hexadecimal system can be used in floating-point arithmetic, but also to represent numerically the strings of ASCII characters.

It’s also used in the representation of RGB colors in a compact format. To state that we’re representing colors, we conventionally place a hash symbol # first. Then, we follow it with a sequence of three hexadecimal numbers comprised between 00_{16} and FF_{16}:

  • Pure red: (255,0,0)_{RGB} =#FF0000
  • Pure green: (0,255,0)_{RGB} =#00FF00
  • Pure blue: (0,0,255)_{RGB} =#0000FF
  • Baeldung light green: (99,177,117)_{RGB} =#63B175
  • Baeldung light blue: (102,146,227)_{RGB} =#6692E3

Notice that these hexadecimal numbers are three per string, not one, each of them comprising two digits per color.

5. Conclusion

In this article, we studied numeral systems and their associated concepts.

We started by discussing the unary, non-positional numeral system, as well as the decimal system.

As an alternative to the latter, we then studied the binary, the octal, and the hexadecimal systems that we frequently use in computer science.